latest updates

This commit is contained in:
Tyrel Souza 2024-04-25 13:43:20 -04:00
parent b56f86a1cd
commit 5e4304da40
No known key found for this signature in database
GPG Key ID: F3614B02ACBE438E
7 changed files with 106 additions and 25 deletions

View File

@ -14,5 +14,5 @@ clean:
###############################################################################
# Rule to run the final cartridge .nes file in the FCEUX emulator
###############################################################################
run:
run: build
fceux clearmem.nes

View File

@ -240,7 +240,6 @@ DoneIncrementing:
jmp LoadPaletteBytes
:
LoadPaletteBytes:
PPU_SETADDR $3F00
ldy #0 ; Y = 0
@ -810,29 +809,41 @@ FinishCollisionCheck:
rts
.endproc
.proc LoadTitleScreen
lda #<TitleScreenData
sta BgPtr
.proc LoadTitleScreenRLE ; uses RLE
lda #>TitleScreenData
sta BgPtr+1
lda #<TitleScreenData
sta BgPtr+0
PPU_SETADDR $2000
ldx #$00
ldy #$00
OuterLoop:
InnerLoop:
lda (BgPtr),y
sta PPU_DATA
iny
cpy #0
beq IncreaseHiByte
jmp InnerLoop
IncreaseHiByte:
inc BgPtr+1
inx
cpx #4
bne OuterLoop
ldy #0
LengthLoop:
lda (BgPtr),y
beq EndRoutine
iny
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
@ -874,7 +885,7 @@ Reset:
sta MenuItem
jsr LoadPalette
jsr LoadTitleScreen ; Load tiles and attributes to the PPU
jsr LoadTitleScreenRLE ; Load tiles and attributes to the PPU
lda #0
sta MenuItem
@ -1451,7 +1462,7 @@ AttributeData:
TitleScreenData:
.incbin "titlescreen.nam"
.incbin "titlescreen.rle"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Binary file not shown.

Binary file not shown.

70
atlantico/rle.py Executable file
View 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

Binary file not shown.

Binary file not shown.