diff --git a/blk/620 b/blk/620 index bce2e02..de07603 100644 --- a/blk/620 +++ b/blk/620 @@ -1,3 +1,3 @@ Sega Master System Recipe -622 VDP +622 VDP 630 PAD diff --git a/blk/622 b/blk/622 index e640ba1..dfd90b6 100644 --- a/blk/622 +++ b/blk/622 @@ -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 help readability. -Load range: 623-623 +Load range: 623-628 diff --git a/blk/630 b/blk/630 new file mode 100644 index 0000000..ccfced2 --- /dev/null +++ b/blk/630 @@ -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.) diff --git a/blk/631 b/blk/631 new file mode 100644 index 0000000..f8a16e3 --- /dev/null +++ b/blk/631 @@ -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 + diff --git a/blk/632 b/blk/632 new file mode 100644 index 0000000..be43e4e --- /dev/null +++ b/blk/632 @@ -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. ) diff --git a/blk/633 b/blk/633 new file mode 100644 index 0000000..61a537c --- /dev/null +++ b/blk/633 @@ -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 diff --git a/blk/634 b/blk/634 new file mode 100644 index 0000000..4054ca3 --- /dev/null +++ b/blk/634 @@ -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 +; diff --git a/blk/635 b/blk/635 new file mode 100644 index 0000000..34dd558 --- /dev/null +++ b/blk/635 @@ -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 < +; diff --git a/blk/636 b/blk/636 new file mode 100644 index 0000000..8908c50 --- /dev/null +++ b/blk/636 @@ -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@ +; diff --git a/blk/637 b/blk/637 new file mode 100644 index 0000000..39cffdb --- /dev/null +++ b/blk/637 @@ -0,0 +1,2 @@ +: PAD$ + 0xff _prevstat C! 'a' _sel C! 0 _next C! ; diff --git a/recipes/sms/xcomp.fs b/recipes/sms/xcomp.fs index e3fa460..7318f3d 100644 --- a/recipes/sms/xcomp.fs +++ b/recipes/sms/xcomp.fs @@ -8,6 +8,9 @@ RAMSTART 0x70 + CONSTANT VDP_MEM 0xbe CONSTANT VDP_DATAPORT 32 CONSTANT VDP_COLS 24 CONSTANT VDP_ROWS +RAMSTART 0x72 + CONSTANT PAD_MEM +0x3f CONSTANT PAD_CTLPORT +0xdc CONSTANT PAD_D1PORT 212 LOAD ( z80 assembler ) : ZFILL, ( u ) 0 DO 0 A, LOOP ; 262 LOAD ( xcomp ) @@ -23,11 +26,11 @@ CURRENT @ XCURRENT ! 393 LOAD ( xcomp core low ) CREATE ~FNT CPFNT7x7 623 628 LOADR ( VDP ) -: (key) 4 ; +632 637 LOADR ( PAD ) 420 LOAD ( xcomp core high ) (entry) _ ( Update LATEST ) PC ORG @ 8 + ! -," VDP$ " EOT, +," VDP$ PAD$ " EOT, ORG @ 0x100 - 256 /MOD 2 PC! 2 PC! H@ 256 /MOD 2 PC! 2 PC!