1
0
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

731 lines
20 KiB

include "hardware.inc"
include "constants.inc"
include "signals.asm"
include "ops.asm"
include "tick.asm"
; --------------------------------------------------------------------------------------------------------------------
; Interrupt Vectors
; --------------------------------------------------------------------------------------------------------------------
SECTION "Vblank", ROM0[$0040]
jp UpdateTiles
SECTION "LCDC", ROM0[$0048]
reti
SECTION "Timer", ROM0[$0050]
jp Timer
SECTION "Serial", ROM0[$0058]
reti
SECTION "Joypad", ROM0[$0060]
reti
; Entry point
SECTION "Entry", ROM0[$100]
nop
jp start
; --------------------------------------------------------------------------------------------------------------------
; Header
; --------------------------------------------------------------------------------------------------------------------
SECTION "Header",ROM0[$0104]
; Logo
DB $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83,$00,$0C,$00,$0D
DB $00,$08,$11,$1F,$88,$89,$00,$0E,$DC,$CC,$6E,$E6,$DD,$DD,$D9,$99
DB $BB,$BB,$67,$63,$6E,$0E,$EC,$CC,$DD,$DC,$99,$9F,$BB,$B9,$33,$3E
; ROM Details
DB "8BIT00000000000" ; $134 - Title (exactly 15 characters)
DB 0 ; $143 - GBC Functionality: No
DB 0,0 ; $144 - Licensee code
DB 0 ; $146 - SGB Support: No
DB 0 ; $147 - Cart type: No MBC (32K ROM only)
DB 0 ; $148 - ROM Size: 32K (No Banking)
DB 0 ; $149 - External ram Size: None
DB 1 ; $14a - Destination: Non-Japan
DB $33 ; $14b - Old Licensee code: must be $33
DB 0 ; $14c - Mask ROM version
DB 0 ; $14d - Complement check (RGBDS will fill)
DW 0 ; $14e - Checksum (RGBDS will fill)
; --------------------------------------------------------------------------------------------------------------------
; Entry Point
; --------------------------------------------------------------------------------------------------------------------
SECTION "Main", ROM0[$150]
start:
di
ld SP, $FFFF
; Turn LCD off
.wait_for_vblank
ldh a, [rLY]
cp 145
jr nz, .wait_for_vblank
ld a, [rLCDC]
xor LCDCF_ON
ld [rLCDC], a
; Load tiles into VRAM
ld hl, _VRAM
ld de, Tiles_Begin
ld bc, Tiles_End-Tiles_Begin
call CopyBytes
; Fill the map
ld hl, _SCRN0
ld de, TileMap_Begin
ld bc, TileMap_End-TileMap_Begin
call CopyBytes
; Set background palette
ld a, %11100100
ld [rBGP], a
; Turn LCD back on
ld a, [rLCDC]
or LCDCF_ON
ld [rLCDC], a
; Set up timer and vblank interrupts
ld a, IEF_TIMER | IEF_VBLANK
ld [rIE], a
; Configure timer
; TODO: Make this adjustable at runtime (clock speed adjust)
ld a, TACF_4KHZ | TACF_START
ld [rTAC], a
xor a
ld [rTMA], a
; Zero all state
ld hl, StateBegin
ld bc, StateEnd-StateBegin
call SetByte
; Zero all values
ld hl, DataBegin
ld bc, DataEnd-DataBegin
call SetByte
; Turn off all LEDs
ld a, LED_OFF
ld hl, LedBegin
ld bc, LedEnd-LedBegin
call SetByte
; Load the program
; TODO: Make this programmable at runtime
ld a, $e0
ld [ram], a ; OUT
ld a, $2f
ld [ram+1], a ; ADD 15
ld a, $74
ld [ram+2], a ; JC 4
ld a, $60
ld [ram+3], a ; JMP 0
ld a, $3f
ld [ram+4], a ; SUB 15
ld a, $e0
ld [ram+5], a ; OUT
ld a, $80
ld [ram+6], a ; JZ 0
ld a, $64
ld [ram+7], a ; JMP 4
xor a
ld [ram+8], a ; NOP
ld [ram+9], a ; NOP
ld [ram+10], a ; NOP
ld [ram+11], a ; NOP
ld [ram+12], a ; NOP
ld [ram+13], a ; NOP
ld [ram+14], a ; NOP
ld a, 15
ld [ram+15], a ; Data
; Load default clock of 1Hz (16 timer interrupts)
ld a, 2
ld [clk], a
ld a, 1
ld [clk_div2], a
; Initialize as running
ld a, 1
ld [running], a
; Tick once before we begin to set the stage
call Tick
ei
.loop
halt
nop
; If we aren't running, loop
ld a, [running]
cp 1
jr nz, .loop
; Check for Button A state
; State is only set once per press; no repeats
call ReadKeys
bit 0, a
jr z, .key_released
.key_pressed:
ld a, LED_ON
ld [clk_led], a
ld a, [button_state]
cp 0
jr z, .tick
jr .loop
.key_released:
xor a
ld [button_state], a
ld a, LED_OFF
ld [clk_led], a
jr .loop
.tick:
; Key press = rising edge
; Key release = falling edge
ld a, 1
ld [button_state], a
call Tick
jr .loop
; [in] de: Source address
; [in] hl: Destination address
; [in] bc: Count
CopyBytes:
; Increment each by one to prevent rolling over when decrementing
inc b
inc c
jr .skip
.loop:
ld a, [de]
ld [hl+], a
inc de
.skip:
dec c
jr nz, .loop
dec b
jr nz, .loop
ret
; [in] a: Byte to set
; [in] hl: Destination address
; [in] bc: Count
SetByte:
; Increment each by one to prevent rolling over when decrementing
inc b
inc c
jr .skip
.loop
ld [hl+], a
.skip:
dec c
jr nz, .loop
dec b
jr nz, .loop
ret
; [out] a: x x x x start select b a
ReadKeys:
ld a, P1F_GET_BTN ;
ld [rP1], a ; joypad info
ld a, [rP1] ;
ld a, [rP1] ; read twice to make sure
and $0f ; low nibble contains buttons
cpl ; low means pressed so we complement for logic purposes
ret
SECTION "Handlers", ROM0
Timer:
push af
ld a, [w_counter]
add a, 1
ld [w_counter], a
ld hl, clk_div2
cp [hl]
jr z, .rising_edge
ld hl, clk
cp [hl]
jr z, .falling_edge
jr .exit
.rising_edge:
ld a, LED_ON
ld [clk_led], a
call Tick
jr .exit
.falling_edge:
ld a, LED_OFF
ld [clk_led], a
xor a
ld [w_counter], a
.exit:
pop af
reti
UpdateTiles:
push af
; CLK
ld hl, _SCRN0 + 4
ld a, [clk_led]
ld [hl], a
; PC
ld hl, _SCRN0 + 13
ld a, [pc_led_3]
ld [hl+], a
ld a, [pc_led_2]
ld [hl+], a
ld a, [pc_led_1]
ld [hl+], a
ld a, [pc_led_0]
ld [hl], a
; OP
ld hl, _SCRN0 + $040 + 14
ld a, [opc_led_2]
ld [hl+], a
ld a, [opc_led_1]
ld [hl+], a
ld a, [opc_led_0]
ld [hl], a
; IR
ld hl, _SCRN0 + $040 + 4
ld a, [ir_led_7]
ld [hl+], a
ld a, [ir_led_6]
ld [hl+], a
ld a, [ir_led_5]
ld [hl+], a
ld a, [ir_led_4]
ld [hl+], a
ld a, [ir_led_3]
ld [hl+], a
ld a, [ir_led_2]
ld [hl+], a
ld a, [ir_led_1]
ld [hl+], a
ld a, [ir_led_0]
ld [hl], a
; MAR
ld hl, _SCRN0 + $080 + 4
ld a, [mar_led_3]
ld [hl+], a
ld a, [mar_led_2]
ld [hl+], a
ld a, [mar_led_1]
ld [hl+], a
ld a, [mar_led_0]
ld [hl], a
; BUS
ld hl, _SCRN0 + $0A0 + 4
ld a, [mem_led_7]
ld [hl+], a
ld a, [mem_led_6]
ld [hl+], a
ld a, [mem_led_5]
ld [hl+], a
ld a, [mem_led_4]
ld [hl+], a
ld a, [mem_led_3]
ld [hl+], a
ld a, [mem_led_2]
ld [hl+], a
ld a, [mem_led_1]
ld [hl+], a
ld a, [mem_led_0]
ld [hl], a
; BUS
ld hl, _SCRN0 + $0E0 + 4
ld a, [bus_led_7]
ld [hl+], a
ld a, [bus_led_6]
ld [hl+], a
ld a, [bus_led_5]
ld [hl+], a
ld a, [bus_led_4]
ld [hl+], a
ld a, [bus_led_3]
ld [hl+], a
ld a, [bus_led_2]
ld [hl+], a
ld a, [bus_led_1]
ld [hl+], a
ld a, [bus_led_0]
ld [hl], a
; A
ld hl, _SCRN0 + $120 + 4
ld a, [a_led_7]
ld [hl+], a
ld a, [a_led_6]
ld [hl+], a
ld a, [a_led_5]
ld [hl+], a
ld a, [a_led_4]
ld [hl+], a
ld a, [a_led_3]
ld [hl+], a
ld a, [a_led_2]
ld [hl+], a
ld a, [a_led_1]
ld [hl+], a
ld a, [a_led_0]
ld [hl], a
; B
ld hl, _SCRN0 + $140 + 4
ld a, [b_led_7]
ld [hl+], a
ld a, [b_led_6]
ld [hl+], a
ld a, [b_led_5]
ld [hl+], a
ld a, [b_led_4]
ld [hl+], a
ld a, [b_led_3]
ld [hl+], a
ld a, [b_led_2]
ld [hl+], a
ld a, [b_led_1]
ld [hl+], a
ld a, [b_led_0]
ld [hl], a
; ALU
ld hl, _SCRN0 + $160 + 4
ld a, [alu_led_7]
ld [hl+], a
ld a, [alu_led_6]
ld [hl+], a
ld a, [alu_led_5]
ld [hl+], a
ld a, [alu_led_4]
ld [hl+], a
ld a, [alu_led_3]
ld [hl+], a
ld a, [alu_led_2]
ld [hl+], a
ld a, [alu_led_1]
ld [hl+], a
ld a, [alu_led_0]
ld [hl], a
; CTRL
ld hl, _SCRN0 + $1A0 + 4
ld a, [ctrl_led_ht]
ld [hl+], a
ld a, [ctrl_led_mi]
ld [hl+], a
ld a, [ctrl_led_ri]
ld [hl+], a
ld a, [ctrl_led_ro]
ld [hl+], a
ld a, [ctrl_led_io]
ld [hl+], a
ld a, [ctrl_led_ii]
ld [hl+], a
ld a, [ctrl_led_ai]
ld [hl+], a
ld a, [ctrl_led_ao]
ld [hl+], a
ld a, [ctrl_led_eo]
ld [hl+], a
ld a, [ctrl_led_su]
ld [hl+], a
ld a, [ctrl_led_bi]
ld [hl+], a
ld a, [ctrl_led_oi]
ld [hl+], a
ld a, [ctrl_led_ce]
ld [hl+], a
ld a, [ctrl_led_co]
ld [hl+], a
ld a, [ctrl_led_jp]
ld [hl+], a
ld a, [ctrl_led_fi]
ld [hl], a
; Flags
ld hl, _SCRN0 + $160 + 13
ld a, [flag_led_c]
ld [hl+], a
ld a, [flag_led_z]
ld [hl], a
; OUT
ld hl, _SCRN0 + $220 + 4
; 100s
ld a, [display]
add a, $1 ; $1 = tile id of 0
ld [hl+], a
; 10s
ld a, [display+1]
add a, $1
ld [hl+], a
; 1s
ld a, [display+2]
add a, $1
ld [hl], a
.exit
pop af
reti
; --------------------------------------------------------------------------------------------------------------------
; Tile Data
; --------------------------------------------------------------------------------------------------------------------
SECTION "Tile Data", ROM0
Tiles_Begin:
DB $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF ; Blank ($00)
DB $83,$83,$7D,$7D,$6D,$6D,$6D,$6D,$6D,$6D,$7D,$7D,$83,$83,$FF,$FF ; 0 ($01)
DB $EF,$EF,$EF,$EF,$EF,$EF,$EF,$EF,$EF,$EF,$EF,$EF,$EF,$EF,$FF,$FF ; 1 ($02)
DB $07,$07,$FB,$FB,$FB,$FB,$87,$87,$7F,$7F,$7F,$7F,$03,$03,$FF,$FF ; 2 ($03)
DB $03,$03,$FD,$FD,$FD,$FD,$83,$83,$FD,$FD,$FD,$FD,$03,$03,$FF,$FF ; 3 ($04)
DB $7D,$7D,$7D,$7D,$7D,$7D,$81,$81,$FD,$FD,$FD,$FD,$FD,$FD,$FF,$FF ; 4 ($05)
DB $03,$03,$7F,$7F,$7F,$7F,$07,$07,$FB,$FB,$FB,$FB,$07,$07,$FF,$FF ; 5 ($06)
DB $83,$83,$7F,$7F,$7F,$7F,$03,$03,$7D,$7D,$7D,$7D,$83,$83,$FF,$FF ; 6 ($07)
DB $01,$01,$FD,$FD,$FD,$FD,$FD,$FD,$FD,$FD,$FD,$FD,$FD,$FD,$FF,$FF ; 7 ($08)
DB $83,$83,$7D,$7D,$7D,$7D,$83,$83,$7D,$7D,$7D,$7D,$83,$83,$FF,$FF ; 8 ($09)
DB $83,$83,$7D,$7D,$7D,$7D,$81,$81,$FD,$FD,$FD,$FD,$FD,$FD,$FF,$FF ; 9 ($0A)
DB $C7,$C7,$BB,$BB,$7D,$7D,$7D,$7D,$01,$01,$7D,$7D,$7D,$7D,$FF,$FF ; A ($0B)
DB $03,$03,$7D,$7D,$7D,$7D,$03,$03,$7D,$7D,$7D,$7D,$03,$03,$FF,$FF ; B ($0C)
DB $83,$83,$7D,$7D,$7F,$7F,$7F,$7F,$7F,$7F,$7D,$7D,$83,$83,$FF,$FF ; C ($0D)
DB $03,$03,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$03,$03,$FF,$FF ; D ($0E)
DB $83,$83,$7F,$7F,$7F,$7F,$07,$07,$7F,$7F,$7F,$7F,$83,$83,$FF,$FF ; E ($0F)
DB $01,$01,$7F,$7F,$7F,$7F,$03,$03,$7F,$7F,$7F,$7F,$7F,$7F,$FF,$FF ; F ($10)
DB $83,$83,$7D,$7D,$7F,$7F,$61,$61,$7D,$7D,$7D,$7D,$83,$83,$FF,$FF ; G ($11)
DB $7D,$7D,$7D,$7D,$7D,$7D,$01,$01,$7D,$7D,$7D,$7D,$7D,$7D,$FF,$FF ; H ($12)
DB $01,$01,$EF,$EF,$EF,$EF,$EF,$EF,$EF,$EF,$EF,$EF,$01,$01,$FF,$FF ; I ($13)
DB $01,$01,$F7,$F7,$F7,$F7,$F7,$F7,$77,$77,$77,$77,$8F,$8F,$FF,$FF ; J ($14)
DB $7B,$7B,$7B,$7B,$7B,$7B,$07,$07,$7B,$7B,$7B,$7B,$7B,$7B,$FF,$FF ; K ($15)
DB $7F,$7F,$7F,$7F,$7F,$7F,$7F,$7F,$7F,$7F,$7F,$7F,$03,$03,$FF,$FF ; L ($16)
DB $BB,$BB,$55,$55,$6D,$6D,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$FF,$FF ; M ($17)
DB $03,$03,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$FF,$FF ; N ($18)
DB $83,$83,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$83,$83,$FF,$FF ; O ($19)
DB $03,$03,$7D,$7D,$7D,$7D,$03,$03,$7F,$7F,$7F,$7F,$7F,$7F,$FF,$FF ; P ($1A)
DB $83,$83,$7D,$7D,$7D,$7D,$7D,$7D,$75,$75,$7B,$7B,$85,$85,$FF,$FF ; Q ($1B)
DB $83,$83,$7D,$7D,$7D,$7D,$03,$03,$7D,$7D,$7D,$7D,$7D,$7D,$FF,$FF ; R ($1C)
DB $81,$81,$7F,$7F,$7F,$7F,$83,$83,$FD,$FD,$FD,$FD,$03,$03,$FF,$FF ; S ($1D)
DB $01,$01,$EF,$EF,$EF,$EF,$EF,$EF,$EF,$EF,$EF,$EF,$EF,$EF,$FF,$FF ; T ($1E)
DB $7D,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$83,$83,$FF,$FF ; U ($1F)
DB $7D,$7D,$7D,$7D,$BB,$BB,$BB,$BB,$D7,$D7,$D7,$D7,$EF,$EF,$FF,$FF ; V ($20)
DB $7D,$7D,$7D,$7D,$7D,$7D,$7D,$7D,$6D,$6D,$55,$55,$BB,$BB,$FF,$FF ; W ($21)
DB $7D,$7D,$BB,$BB,$D7,$D7,$EF,$EF,$D7,$D7,$BB,$BB,$7D,$7D,$FF,$FF ; X ($22)
DB $7D,$7D,$7D,$7D,$BB,$BB,$D7,$D7,$EF,$EF,$EF,$EF,$EF,$EF,$FF,$FF ; Y ($23)
DB $01,$01,$FD,$FD,$FB,$FB,$C7,$C7,$BF,$BF,$7F,$7F,$01,$01,$FF,$FF ; Z ($24)
DB $FF,$83,$83,$7D,$83,$7D,$83,$7D,$83,$7D,$83,$7D,$FF,$83,$FF,$FF ; LED Off ($25)
DB $FF,$83,$83,$01,$83,$01,$83,$01,$83,$01,$83,$01,$FF,$83,$FF,$FF ; LED On ($26)
Tiles_End:
; --------------------------------------------------------------------------------------------------------------------
; Tile Map
; --------------------------------------------------------------------------------------------------------------------
SECTION "Tile Map", ROM0
TileMap_Begin:
DB $0D,$16,$15,$00,$25,$00,$00,$00,$00,$00,$00,$00,$00,$25,$25,$25,$25,$00,$1A,$0D, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; [$000] CLK PC
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; [$020]
DB $00,$13,$1C,$00,$25,$25,$25,$25,$25,$25,$25,$25,$00,$00,$25,$25,$25,$00,$19,$1A, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; [$040] IR OP
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; [$060]
DB $17,$0B,$1C,$00,$25,$25,$25,$25,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; [$080] MAR
DB $17,$0F,$17,$00,$25,$25,$25,$25,$25,$25,$25,$25,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; [$0A0] MEM
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; [$0C0]
DB $0C,$1F,$1D,$00,$25,$25,$25,$25,$25,$25,$25,$25,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; [$0E0] BUS
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; [$100]
DB $00,$00,$0B,$00,$25,$25,$25,$25,$25,$25,$25,$25,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; [$120] A
DB $00,$00,$0C,$00,$25,$25,$25,$25,$25,$25,$25,$25,$00,$0D,$24,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; [$140] B C Z
DB $0B,$16,$1F,$00,$25,$25,$25,$25,$25,$25,$25,$25,$00,$25,$25,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; [$160] ALU x x
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; [$080]
DB $0D,$1E,$16,$00,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; [$1A0] CTL
DB $00,$00,$00,$00,$12,$17,$1C,$1C,$13,$13,$0B,$0B,$0F,$1D,$0C,$19,$0D,$0D,$14,$10, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; [$1C0] H M R R I I A A E S B O C C J F
DB $00,$00,$00,$00,$1E,$13,$13,$19,$19,$13,$13,$19,$19,$1F,$13,$13,$0F,$19,$1A,$13, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; [$1E0] T I I O O I I O O U I I E O P I
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; [$200]
DB $19,$1F,$1E,$00,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; [$220] OUT
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
TileMap_End:
; --------------------------------------------------------------------------------------------------------------------
; State
; --------------------------------------------------------------------------------------------------------------------
SECTION "State", WRAM0
StateBegin:
w_counter: DS 1
clk: DS 1
clk_div2: DS 1
button_state: DS 1
running: DS 1
flags_temp: DS 1
StateEnd:
; --------------------------------------------------------------------------------------------------------------------
; Data
; --------------------------------------------------------------------------------------------------------------------
SECTION "Data", WRAM0
DataBegin:
bus: DS 1 ; 8 bit
mar: DS 1 ; 4 bit
mem: DS 1 ; 8 bit
ir: DS 1 ; 8 bit
pc: DS 1 ; 4 bit
opc: DS 1 ; 3 bit
a_reg: DS 1 ; 8 bit
b_reg: DS 1 ; 8 bit
alu: DS 1 ; 8 bit
out_reg: DS 1 ; 8 bit
ctrl: DS 2 ; ht | mi | ri | ro | io | ii | ai | ao || eo | su | bi | oi | ce | co | jp | fi
flags: DS 1 ; c | z
ram: DS 16
DataEnd:
; --------------------------------------------------------------------------------------------------------------------
; LEDs
; --------------------------------------------------------------------------------------------------------------------
SECTION "LEDs", WRAM0
LedBegin:
clk_led: DS 1
bus_led_7: DS 1
bus_led_6: DS 1
bus_led_5: DS 1
bus_led_4: DS 1
bus_led_3: DS 1
bus_led_2: DS 1
bus_led_1: DS 1
bus_led_0: DS 1
mar_led_3: DS 1
mar_led_2: DS 1
mar_led_1: DS 1
mar_led_0: DS 1
mem_led_7: DS 1
mem_led_6: DS 1
mem_led_5: DS 1
mem_led_4: DS 1
mem_led_3: DS 1
mem_led_2: DS 1
mem_led_1: DS 1
mem_led_0: DS 1
opc_led_2: DS 1
opc_led_1: DS 1
opc_led_0: DS 1
pc_led_3: DS 1
pc_led_2: DS 1
pc_led_1: DS 1
pc_led_0: DS 1
ir_led_7: DS 1
ir_led_6: DS 1
ir_led_5: DS 1
ir_led_4: DS 1
ir_led_3: DS 1
ir_led_2: DS 1
ir_led_1: DS 1
ir_led_0: DS 1
a_led_7: DS 1
a_led_6: DS 1
a_led_5: DS 1
a_led_4: DS 1
a_led_3: DS 1
a_led_2: DS 1
a_led_1: DS 1
a_led_0: DS 1
b_led_7: DS 1
b_led_6: DS 1
b_led_5: DS 1
b_led_4: DS 1
b_led_3: DS 1
b_led_2: DS 1
b_led_1: DS 1
b_led_0: DS 1
alu_led_7: DS 1
alu_led_6: DS 1
alu_led_5: DS 1
alu_led_4: DS 1
alu_led_3: DS 1
alu_led_2: DS 1
alu_led_1: DS 1
alu_led_0: DS 1
ctrl_led_ht: DS 1
ctrl_led_mi: DS 1
ctrl_led_ri: DS 1
ctrl_led_ro: DS 1
ctrl_led_io: DS 1
ctrl_led_ii: DS 1
ctrl_led_ai: DS 1
ctrl_led_ao: DS 1
ctrl_led_eo: DS 1
ctrl_led_su: DS 1
ctrl_led_bi: DS 1
ctrl_led_oi: DS 1
ctrl_led_ce: DS 1
ctrl_led_co: DS 1
ctrl_led_jp: DS 1
ctrl_led_fi: DS 1
flag_led_c: DS 1
flag_led_z: DS 1
display: DS 3 ; 3 digits
LedEnd: