latest updates
This commit is contained in:
parent
b56f86a1cd
commit
5e4304da40
2
Makefile
2
Makefile
@ -14,5 +14,5 @@ clean:
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
# Rule to run the final cartridge .nes file in the FCEUX emulator
|
# Rule to run the final cartridge .nes file in the FCEUX emulator
|
||||||
###############################################################################
|
###############################################################################
|
||||||
run:
|
run: build
|
||||||
fceux clearmem.nes
|
fceux clearmem.nes
|
||||||
|
@ -240,7 +240,6 @@ DoneIncrementing:
|
|||||||
jmp LoadPaletteBytes
|
jmp LoadPaletteBytes
|
||||||
:
|
:
|
||||||
|
|
||||||
|
|
||||||
LoadPaletteBytes:
|
LoadPaletteBytes:
|
||||||
PPU_SETADDR $3F00
|
PPU_SETADDR $3F00
|
||||||
ldy #0 ; Y = 0
|
ldy #0 ; Y = 0
|
||||||
@ -810,30 +809,42 @@ FinishCollisionCheck:
|
|||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
.proc LoadTitleScreen
|
|
||||||
lda #<TitleScreenData
|
|
||||||
sta BgPtr
|
|
||||||
lda #>TitleScreenData
|
|
||||||
sta BgPtr+1
|
|
||||||
|
|
||||||
PPU_SETADDR $2000
|
.proc LoadTitleScreenRLE ; uses RLE
|
||||||
ldx #$00
|
lda #>TitleScreenData
|
||||||
ldy #$00
|
sta BgPtr+1
|
||||||
OuterLoop:
|
lda #<TitleScreenData
|
||||||
InnerLoop:
|
sta BgPtr+0
|
||||||
lda (BgPtr),y
|
|
||||||
sta PPU_DATA
|
PPU_SETADDR $2000
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
|
||||||
|
LengthLoop:
|
||||||
|
lda (BgPtr),y
|
||||||
|
beq EndRoutine
|
||||||
iny
|
iny
|
||||||
cpy #0
|
|
||||||
beq IncreaseHiByte
|
|
||||||
jmp InnerLoop
|
|
||||||
IncreaseHiByte:
|
|
||||||
inc BgPtr+1
|
|
||||||
inx
|
|
||||||
cpx #4
|
|
||||||
bne OuterLoop
|
|
||||||
|
|
||||||
rts
|
bne :+
|
||||||
|
inc BgPtr+1
|
||||||
|
:
|
||||||
|
|
||||||
|
tax
|
||||||
|
lda (BgPtr),y
|
||||||
|
iny
|
||||||
|
|
||||||
|
bne :+
|
||||||
|
inc BgPtr+1
|
||||||
|
:
|
||||||
|
|
||||||
|
TileLoop:
|
||||||
|
sta PPU_DATA
|
||||||
|
dex
|
||||||
|
bne TileLoop
|
||||||
|
jmp LengthLoop
|
||||||
|
|
||||||
|
EndRoutine:
|
||||||
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
@ -874,7 +885,7 @@ Reset:
|
|||||||
sta MenuItem
|
sta MenuItem
|
||||||
|
|
||||||
jsr LoadPalette
|
jsr LoadPalette
|
||||||
jsr LoadTitleScreen ; Load tiles and attributes to the PPU
|
jsr LoadTitleScreenRLE ; Load tiles and attributes to the PPU
|
||||||
|
|
||||||
lda #0
|
lda #0
|
||||||
sta MenuItem
|
sta MenuItem
|
||||||
@ -1451,7 +1462,7 @@ AttributeData:
|
|||||||
|
|
||||||
|
|
||||||
TitleScreenData:
|
TitleScreenData:
|
||||||
.incbin "titlescreen.nam"
|
.incbin "titlescreen.rle"
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
Binary file not shown.
Binary file not shown.
70
atlantico/rle.py
Executable file
70
atlantico/rle.py
Executable file
@ -0,0 +1,70 @@
|
|||||||
|
###############################################################################
|
||||||
|
# RLE encoder
|
||||||
|
###############################################################################
|
||||||
|
# Takes any binary file and converts to RLE sequenced (ended with length 0)
|
||||||
|
# Input: FF FF FF FF FF FF FF FF FF 0A FF FF FF
|
||||||
|
# Output: 09 FF 01 0A 03 FF 00
|
||||||
|
###############################################################################
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import math
|
||||||
|
|
||||||
|
input = sys.argv[1]
|
||||||
|
|
||||||
|
if len(sys.argv) == 1:
|
||||||
|
print("Usage:\n $ python3 ./rle.py <BIN_FILENAME>\n\nOutput .rle format.")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
def compress(data):
|
||||||
|
output = []
|
||||||
|
i = 1
|
||||||
|
total = 0
|
||||||
|
char = data[0]
|
||||||
|
count = 1
|
||||||
|
|
||||||
|
while i <= len(data):
|
||||||
|
if i == len(data):
|
||||||
|
output.append(bytes([count]))
|
||||||
|
output.append(bytes([char]))
|
||||||
|
total += count
|
||||||
|
break
|
||||||
|
if char == data[i]:
|
||||||
|
count += 1
|
||||||
|
if count == 255:
|
||||||
|
total += count
|
||||||
|
output.append(bytes([count]))
|
||||||
|
output.append(bytes([char]))
|
||||||
|
count = 0
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
total += count
|
||||||
|
output.append(bytes([count]))
|
||||||
|
output.append(bytes([char]))
|
||||||
|
count = 1
|
||||||
|
char = data[i]
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
print(total, "bytes compresed to", len(output))
|
||||||
|
return output
|
||||||
|
|
||||||
|
def read_file_bytes(file):
|
||||||
|
with open(file, 'rb') as f:
|
||||||
|
return f.read()
|
||||||
|
|
||||||
|
def read_file(input):
|
||||||
|
inbytes = read_file_bytes(input)
|
||||||
|
output = compress(inbytes)
|
||||||
|
f = None
|
||||||
|
try:
|
||||||
|
f = open(input.split('.')[0]+".rle", "wb")
|
||||||
|
for b in output:
|
||||||
|
f.write(b)
|
||||||
|
f.write(b'\x00')
|
||||||
|
finally:
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
read_file(input)
|
||||||
|
|
||||||
|
print("File written successfully.")
|
BIN
atlantico/titlescreen.rle
Normal file
BIN
atlantico/titlescreen.rle
Normal file
Binary file not shown.
BIN
clearmem.o
BIN
clearmem.o
Binary file not shown.
Loading…
Reference in New Issue
Block a user