1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 11:38:07 +11:00

sms: Pad WIP

This commit is contained in:
Virgil Dupras 2020-05-15 15:41:06 -04:00
parent 1597f1e131
commit f9a8e6f180
11 changed files with 84 additions and 4 deletions

View File

@ -1,3 +1,3 @@
Sega Master System Recipe Sega Master System Recipe
622 VDP 622 VDP 630 PAD

View File

@ -13,4 +13,4 @@ the screen is reached, we wrap up to the top.
When reaching a new line, we clear that line and the next to When reaching a new line, we clear that line and the next to
help readability. help readability.
Load range: 623-623 Load range: 623-628

16
blk/630 Normal file
View File

@ -0,0 +1,16 @@
Pad driver - read input from MD controller
Conveniently expose an API to read the status of a MD pad A.
Moreover, implement a mechanism to input arbitrary characters
from it. It goes as follow:
* Direction pad select characters. Up/Down move by one,
Left/Right move by 5
* Start acts like Return
* A acts like Backspace
* B changes "character class": lowercase, uppercase, numbers,
special chars. The space character is the first among special
chars.
* C confirms letter selection
(cont.)

6
blk/631 Normal file
View File

@ -0,0 +1,6 @@
This module is currently hard-wired to VDP driver, that is, it
calls vdp's routines during (key) to update character
selection.
Load range: 632-637

12
blk/632 Normal file
View File

@ -0,0 +1,12 @@
: _prevstat [ PAD_MEM LITN ] ;
: _sel [ PAD_MEM 1+ LITN ] ;
: _next [ PAD_MEM 2+ LITN ] ;
( Put status for port A in register A. Bits, from MSB to LSB:
Start - A - C - B - Right - Left - Down - Up
Each bit is high when button is unpressed and low if button is
pressed. When no button is pressed, 0xff is returned.
This logic below is for the Genesis controller, which is modal.
TH is an output pin that swiches the meaning of TL and TR. When
TH is high (unselected), TL = Button B and TR = Button C. When
TH is low (selected), TL = Button A and TR = Start. )

15
blk/633 Normal file
View File

@ -0,0 +1,15 @@
CODE _status
A 0b11111101 LDrn, ( TH output, unselected )
PAD_CTLPORT OUTnA,
PAD_D1PORT INAn,
0x3f ANDn, ( low 6 bits are good )
B A LDrr, ( let's store them )
( Start and A are returned when TH is selected, in bits 5 and
4. Well get them, left-shift them and integrate them to B. )
A 0b11011101 LDrn, ( TH output, selected )
PAD_CTLPORT OUTnA,
PAD_D1PORT INAn,
0b00110000 ANDn,
A SLAr, A SLAr, B ORr,
PUSHA,
;CODE

5
blk/634 Normal file
View File

@ -0,0 +1,5 @@
: _chk ( c --, check _sel range )
_sel C@ DUP 0x7f > IF 0x20 _sel C! THEN
0x20 < IF 0x7f _sel C! THEN ;
: _nxtcls
;

13
blk/635 Normal file
View File

@ -0,0 +1,13 @@
: _updsel ( -- f, has an action button been pressed? )
_status _prevstat C@ OVER = IF DROP 0 EXIT THEN
DUP _prevstat C! ( changed, update ) ( s )
0x01 ( UP ) OVER AND NOT IF 1 _sel +! THEN
0x02 ( DOWN ) OVER AND NOT IF -1 _sel +! THEN
0x04 ( LEFT ) OVER AND NOT IF -5 _sel +! THEN
0x08 ( RIGHT ) OVER AND NOT IF 5 _sel +! THEN
0x10 ( BUTB ) OVER AND NOT IF _nxtcls THEN
( update sel in VDP )
_sel C@ (emit) -1 XYPOS +!
( return whether any of the high 3 bits is low )
0xe0 AND 0xe0 <
;

8
blk/636 Normal file
View File

@ -0,0 +1,8 @@
: (key)
BEGIN _updsel UNTIL
_prevstat C@
0x20 ( BUTC ) OVER AND NOT IF THEN
0x40 ( BUTA ) AND NOT IF THEN
( If not BUTC or BUTA, it has to be START )
_sel C@
;

2
blk/637 Normal file
View File

@ -0,0 +1,2 @@
: PAD$
0xff _prevstat C! 'a' _sel C! 0 _next C! ;

View File

@ -8,6 +8,9 @@ RAMSTART 0x70 + CONSTANT VDP_MEM
0xbe CONSTANT VDP_DATAPORT 0xbe CONSTANT VDP_DATAPORT
32 CONSTANT VDP_COLS 32 CONSTANT VDP_COLS
24 CONSTANT VDP_ROWS 24 CONSTANT VDP_ROWS
RAMSTART 0x72 + CONSTANT PAD_MEM
0x3f CONSTANT PAD_CTLPORT
0xdc CONSTANT PAD_D1PORT
212 LOAD ( z80 assembler ) 212 LOAD ( z80 assembler )
: ZFILL, ( u ) 0 DO 0 A, LOOP ; : ZFILL, ( u ) 0 DO 0 A, LOOP ;
262 LOAD ( xcomp ) 262 LOAD ( xcomp )
@ -23,11 +26,11 @@ CURRENT @ XCURRENT !
393 LOAD ( xcomp core low ) 393 LOAD ( xcomp core low )
CREATE ~FNT CPFNT7x7 CREATE ~FNT CPFNT7x7
623 628 LOADR ( VDP ) 623 628 LOADR ( VDP )
: (key) 4 ; 632 637 LOADR ( PAD )
420 LOAD ( xcomp core high ) 420 LOAD ( xcomp core high )
(entry) _ (entry) _
( Update LATEST ) ( Update LATEST )
PC ORG @ 8 + ! PC ORG @ 8 + !
," VDP$ " EOT, ," VDP$ PAD$ " EOT,
ORG @ 0x100 - 256 /MOD 2 PC! 2 PC! ORG @ 0x100 - 256 /MOD 2 PC! 2 PC!
H@ 256 /MOD 2 PC! 2 PC! H@ 256 /MOD 2 PC! 2 PC!