6502/makecounter.py

26 lines
571 B
Python
Raw Permalink Normal View History

#
# Please see this video for details:
# https://www.youtube.com/watch?v=yl8vPW5hydQ
#
code = bytearray([
0xa9, 0xff, # lda #$ff # set output register B
0x8d, 0x02, 0x60, # sta $6002
0xa9, 0x00, # lda #$00 # Start at 0
0x8d, 0x00, 0x60, # sta $6000 # Latch out
0x69, 0x01, # add #$1
0x4c, 0x07, 0x80, # jmp $8005 # go back to first output
])
rom = code + bytearray([0xea] * (32768 - len(code)))
# Reset Vector
rom[0x7ffc] = 0x00
rom[0x7ffd] = 0x80
with open("rom-counter.bin", "wb") as out_file:
out_file.write(rom)