Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .memorymap
- defaultslot 0
- slotsize $8000
- slot 0 $0000
- .endme
- .rombankmap
- bankstotal 1
- banksize $8000
- banks 1
- .endro
- .define VDPControl $bf
- .define VDPStatus $bf
- .define VDPData $be
- .define VRAMWrite $4000
- .define CRAMWrite $c000
- .define Joypad1 $dc
- .define Joypad2 $dd
- .define PSTATUS $c000
- .define PSTATUS2 $c001
- .define JOYSTATUS $c002
- .define JOYSTATUS2 $c003
- .bank 0 slot 0
- .org $0000
- di
- im 1
- jp main
- .org $0066
- retn
- .org $0038
- push af
- in a,(VDPStatus)
- push bc
- call VBlankRoutine
- pop bc
- pop af
- ei
- reti
- main:
- ld sp, $dff0
- di
- ld hl,VDPInitData
- ld b,VDPInitDataEnd-VDPInitData
- ld c,VDPControl
- otir
- ld hl,$0000 | VRAMWrite
- call SetVDPAddress
- ld bc,$4000
- -: xor a
- out (VDPData),a
- dec bc
- ld a,b
- or c
- jr nz,-
- ld hl,$0000 | CRAMWrite
- call SetVDPAddress
- ld hl,PaletteData
- ld bc,PaletteDataEnd-PaletteData
- call CopyToVDP
- ld hl,$0000 | VRAMWrite
- call SetVDPAddress
- ld hl,FontData
- ld bc,FontDataSize
- call CopyToVDP
- ld hl,$3800 | VRAMWrite
- call SetVDPAddress
- ld hl,Message
- -: ld a,(hl)
- cp $ff
- jr z,+
- out (VDPData),a
- xor a
- out (VDPData),a
- inc hl
- jr -
- +:
- ld a,%01100000
- out (VDPControl),a
- ld a,$81
- out (VDPControl),a
- ld a,%00000001
- ld (PSTATUS),a
- ei
- MainLoop:
- ld a,(JOYSTATUS)
- and %00000100
- jr z,MainLoop
- ld b,a
- ld a,(JOYSTATUS2)
- xor b
- and %00000100
- call nz,ZapperPressed
- jr MainLoop
- VBlankRoutine:
- ld bc,(JOYSTATUS)
- ld (JOYSTATUS2),bc
- in a,(Joypad2)
- and %10000100
- ld (JOYSTATUS),a
- ret
- ZapperPressed:
- ld bc,PaletteDataEnd-PaletteData
- ld a,(PSTATUS)
- xor $01
- ld (PSTATUS),a
- and $01
- jr z,_ll2
- ld hl,$0000 | CRAMWrite
- call SetVDPAddress
- ld hl,WPaletteData
- jr _ll3
- _ll2:
- ld hl,$0000 | CRAMWrite
- call SetVDPAddress
- ld hl,PaletteData
- _ll3:
- call CopyToVDP
- ret
- SetVDPAddress:
- push af
- ld a,l
- out (VDPControl),a
- ld a,h
- out (VDPControl),a
- pop af
- ret
- CopyToVDP:
- -: ld a,(hl)
- out (VDPData),a
- inc hl
- dec bc
- ld a,b
- or c
- jr nz,-
- ret
- .asciitable
- map " " to "~" = 0
- .enda
- Message:
- .asc "0"
- .db $ff
- PaletteData:
- .db $00,$3f
- PaletteDataEnd:
- WPaletteData:
- .db $3f,$00
- WPaletteDataEnd:
- ; VDP initialisation data
- VDPInitData:
- .db $04,$80,$00,$81,$ff,$82,$ff,$85,$ff,$86,$ff,$87,$00,$88,$00,$89,$ff,$8a
- VDPInitDataEnd:
- FontData:
- .incbin "font.bin" fsize FontDataSize
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement