diff --git a/Makefile b/Makefile index 59acb56..b7f9563 100755 --- a/Makefile +++ b/Makefile @@ -14,5 +14,5 @@ clean: ############################################################################### # Rule to run the final cartridge .nes file in the FCEUX emulator ############################################################################### -run: +run: build fceux clearmem.nes diff --git a/atlantico/atlantico.asm b/atlantico/atlantico.asm index 473e835..f356e74 100755 --- a/atlantico/atlantico.asm +++ b/atlantico/atlantico.asm @@ -240,7 +240,6 @@ DoneIncrementing: jmp LoadPaletteBytes : - LoadPaletteBytes: PPU_SETADDR $3F00 ldy #0 ; Y = 0 @@ -810,30 +809,42 @@ FinishCollisionCheck: rts .endproc -.proc LoadTitleScreen - lda #TitleScreenData - sta BgPtr+1 - PPU_SETADDR $2000 - ldx #$00 - ldy #$00 - OuterLoop: - InnerLoop: - lda (BgPtr),y - sta PPU_DATA +.proc LoadTitleScreenRLE ; uses RLE + lda #>TitleScreenData + sta BgPtr+1 + lda #\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.") \ No newline at end of file diff --git a/atlantico/titlescreen.rle b/atlantico/titlescreen.rle new file mode 100644 index 0000000..0e6c32c Binary files /dev/null and b/atlantico/titlescreen.rle differ diff --git a/clearmem.o b/clearmem.o index 494017c..7b48be6 100644 Binary files a/clearmem.o and b/clearmem.o differ