2019-07-03 00:49:30 +10:00
|
|
|
; 8K of onboard RAM
|
|
|
|
.equ RAMSTART 0xc000
|
|
|
|
; Memory register at the end of RAM. Must not overwrite
|
|
|
|
.equ RAMEND 0xfdd0
|
|
|
|
|
|
|
|
jp init
|
2019-07-02 01:05:25 +10:00
|
|
|
|
|
|
|
.fill 0x66-$
|
|
|
|
retn
|
|
|
|
|
2019-07-03 01:14:30 +10:00
|
|
|
#include "err.h"
|
|
|
|
#include "core.asm"
|
|
|
|
#include "parse.asm"
|
|
|
|
|
2019-07-03 00:49:30 +10:00
|
|
|
.equ PAD_RAMSTART RAMSTART
|
2019-07-02 23:02:19 +10:00
|
|
|
#include "sms/pad.asm"
|
|
|
|
|
2019-07-03 00:49:30 +10:00
|
|
|
.equ VDP_RAMSTART PAD_RAMEND
|
|
|
|
#include "sms/vdp.asm"
|
|
|
|
|
2019-07-03 01:14:30 +10:00
|
|
|
.equ STDIO_RAMSTART VDP_RAMEND
|
|
|
|
#include "stdio.asm"
|
|
|
|
|
|
|
|
.equ SHELL_RAMSTART STDIO_RAMEND
|
|
|
|
.equ SHELL_EXTRA_CMD_COUNT 0
|
|
|
|
#include "shell.asm"
|
|
|
|
|
2019-07-03 00:49:30 +10:00
|
|
|
init:
|
2019-07-02 23:02:19 +10:00
|
|
|
di
|
|
|
|
im 1
|
|
|
|
|
2019-07-03 00:49:30 +10:00
|
|
|
ld sp, RAMEND
|
2019-07-02 01:05:25 +10:00
|
|
|
|
2019-07-03 01:14:30 +10:00
|
|
|
call padInit
|
2019-07-03 00:49:30 +10:00
|
|
|
call vdpInit
|
2019-07-02 05:46:10 +10:00
|
|
|
|
2019-07-03 01:14:30 +10:00
|
|
|
ld hl, myGetC
|
|
|
|
ld de, vdpPutC
|
|
|
|
call stdioInit
|
|
|
|
call shellInit
|
|
|
|
jp shellLoop
|
2019-07-02 01:05:25 +10:00
|
|
|
|
2019-07-03 01:14:30 +10:00
|
|
|
myGetC:
|
2019-07-02 05:46:10 +10:00
|
|
|
; What we do here is simple. We go though all bits of port A controller
|
|
|
|
; increasing B each time. As soon as we get a hit, we display that
|
|
|
|
; letter. Pressed buttons go low.
|
2019-07-02 23:02:19 +10:00
|
|
|
call padStatusA
|
2019-07-03 01:14:30 +10:00
|
|
|
push bc
|
|
|
|
jr z, .nothing ; unchanged since last poll
|
2019-07-03 00:49:30 +10:00
|
|
|
ld b, 'A'
|
2019-07-02 23:02:19 +10:00
|
|
|
bit 5, a ; Port A Button C pressed
|
2019-07-03 01:14:30 +10:00
|
|
|
jr z, .something
|
2019-07-02 05:46:10 +10:00
|
|
|
inc b ; b
|
2019-07-02 23:02:19 +10:00
|
|
|
bit 4, a ; Port A Button B pressed
|
2019-07-03 01:14:30 +10:00
|
|
|
jr z, .something
|
2019-07-02 05:46:10 +10:00
|
|
|
inc b ; c
|
2019-07-02 23:02:19 +10:00
|
|
|
bit 3, a ; Port A Right pressed
|
2019-07-03 01:14:30 +10:00
|
|
|
jr z, .something
|
2019-07-02 05:46:10 +10:00
|
|
|
inc b ; d
|
2019-07-02 23:02:19 +10:00
|
|
|
bit 2, a ; Port A Left pressed
|
2019-07-03 01:14:30 +10:00
|
|
|
jr z, .something
|
2019-07-02 05:46:10 +10:00
|
|
|
inc b ; e
|
2019-07-02 23:02:19 +10:00
|
|
|
bit 1, a ; Port A Down pressed
|
2019-07-03 01:14:30 +10:00
|
|
|
jr z, .something
|
2019-07-02 05:46:10 +10:00
|
|
|
inc b ; f
|
2019-07-02 23:02:19 +10:00
|
|
|
bit 0, a ; Port A Up pressed
|
2019-07-03 01:14:30 +10:00
|
|
|
jr z, .something
|
2019-07-02 05:46:10 +10:00
|
|
|
inc b ; g
|
2019-07-02 23:02:19 +10:00
|
|
|
bit 6, a ; Port A Button A pressed
|
2019-07-03 01:14:30 +10:00
|
|
|
jr z, .something
|
2019-07-02 05:46:10 +10:00
|
|
|
inc b ; h
|
2019-07-02 23:02:19 +10:00
|
|
|
bit 7, a ; Port A Start pressed
|
2019-07-03 01:14:30 +10:00
|
|
|
jr z, .something
|
|
|
|
; nothing
|
|
|
|
.nothing:
|
|
|
|
pop bc
|
|
|
|
xor a
|
|
|
|
jp unsetZ
|
|
|
|
.something:
|
2019-07-02 06:15:46 +10:00
|
|
|
ld a, b
|
2019-07-03 01:14:30 +10:00
|
|
|
pop bc
|
|
|
|
cp a ; ensure Z
|
|
|
|
ret
|
2019-07-02 01:05:25 +10:00
|
|
|
|
|
|
|
.fill 0x7ff0-$
|
|
|
|
.db "TMR SEGA", 0x00, 0x00, 0xfb, 0x68, 0x00, 0x00, 0x00, 0x4c
|