1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-02 04:20:55 +11:00

Compare commits

...

9 Commits

Author SHA1 Message Date
Virgil Dupras
f2817870aa sms: working on real hardware! 2020-05-15 21:53:26 -04:00
Virgil Dupras
7ceff6144c sms: implement pad button B ( next class ) 2020-05-15 21:18:32 -04:00
Virgil Dupras
b6c039589f Don't emit BS when at beginning of input buffer 2020-05-15 20:51:09 -04:00
Virgil Dupras
aad713c477 sms: implement backspace with pad button A 2020-05-15 20:32:04 -04:00
Virgil Dupras
fdea069544 sms: implement button C and Start in Pad 2020-05-15 17:46:18 -04:00
Virgil Dupras
ebc70be8e8 ti84: use dd instead of truncate
More portable
2020-05-15 17:25:58 -04:00
Virgil Dupras
852c775b5b sms: implement linefeed in VDP 2020-05-15 16:08:27 -04:00
Virgil Dupras
f9a8e6f180 sms: Pad WIP 2020-05-15 15:41:06 -04:00
Virgil Dupras
1597f1e131 Don't generalize XYPOS just yet
It was ill-advised.
2020-05-15 14:09:31 -04:00
23 changed files with 120 additions and 23 deletions

View File

@ -1,6 +1,6 @@
RAMSTART FUTURE USES +3c BLK(*
+02 CURRENT +3e XYPOS
+04 HERE +40 FUTURE USES
+02 CURRENT +3e FUTURE USES
+04 HERE
+06 C<? +51 CURRENTPTR
+08 C<* override +53 (emit) override
+0a NLPTR +55 (key) override

View File

@ -7,8 +7,8 @@ WORDBUF is the buffer used by WORD
BOOT C< PTR is used when Forth boots from in-memory
source. See "Initialization sequence" below.
XYPOS Current position of the cursor on screen. The meaning of
the pos in terms of row and cols is driver-dependent.

View File

@ -3,7 +3,6 @@
: HERE 0x04 RAM+ ;
: CURRENT* 0x51 RAM+ ;
: CURRENT CURRENT* @ ;
: XYPOS 0x40 RAM+ ;
( w -- a f )
: FIND CURRENT @ SWAP _find ;

View File

@ -1,10 +1,10 @@
( handle backspace: go back one char in IN>, if possible, then
emit SPC + BS )
emit BS + SPC + BS )
: (inbs)
( already at IN( ? )
IN> @ IN( = IF EXIT THEN
IN> @ 1- IN> !
SPC BS
BS SPC BS
;
: KEY

12
blk/428
View File

@ -1,16 +1,16 @@
: (rdlnc) ( -- f )
: (rdlnc) ( -- c )
( buffer overflow? same as if we typed a newline )
IN> @ IN) = IF 0x0a ELSE KEY THEN ( c )
IN> @ IN) = IF 0x0a ELSE KEY THEN ( c )
DUP 0x7f = IF DROP 0x8 THEN ( del? same as backspace )
DUP 0x0a = IF DROP 0xd THEN ( lf? same as cr )
( echo back )
DUP EMIT ( c )
( bacspace? handle and exit )
DUP 0x8 = IF (inbs) EXIT THEN
( echo back )
DUP EMIT ( c )
( write and advance )
DUP ( keep as result ) ( c c )
DUP ( keep as result ) ( c c )
( We take advantage of the fact that c's MSB is always zero and
thus ! automatically null-terminates our string )
IN> @ ! 1 IN> +! ( c )
IN> @ ! 1 IN> +! ( c )
( if newline, replace with zero to indicate EOL )
DUP 0xd = IF DROP 0 THEN ;

View File

@ -1,3 +1,3 @@
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
help readability.
Load range: 623-623
Load range: 623-628

View File

@ -1,3 +1,4 @@
: XYPOS [ VDP_MEM LITN ] ;
CODE _ctl ( a -- sends LSB then MSB )
HL POPqq, chkPS,
A L LDrr, VDP_CTLPORT OUTnA,

17
blk/627
View File

@ -1,6 +1,15 @@
: _cell! ( tilenum pos )
2 * 0x7800 OR _ctl ( tilenum ) _data 1 _zero ;
: _spc! 0 ( blank ) XYPOS @ _cell! ;
: _lf
_spc! XYPOS @ [ VDP_COLS LITN ] / 1+ [ VDP_ROWS LITN ] MOD
[ VDP_COLS LITN ] * XYPOS ! ;
: _bs _spc! XYPOS @ 1-
[ VDP_COLS VDP_ROWS * LITN ] MOD XYPOS ! ;
: (emit)
XYPOS @ 2 * 0x7800 OR _ctl
0x20 - 0x5e MIN ( tilenum ) _data 1 _zero
DUP 0x08 = IF DROP _bs EXIT THEN
DUP 0x0d = IF DROP _lf EXIT THEN
0x20 - DUP 0< IF DROP EXIT THEN
0x5e MIN ( tilenum ) XYPOS @ _cell!
XYPOS @ 1+ DUP [ VDP_COLS VDP_ROWS * LITN ]
= IF DROP 0 THEN XYPOS !
;
= IF DROP 0 THEN XYPOS ! ;

View File

@ -6,4 +6,5 @@
( sprite, inverted colors ) 0x3f _data 15 _zero
0x4000 _ctl 0x5e 0 DO ~FNT I 7 * + _sfont LOOP
0 XYPOS !
( bit 6, enable display, bit 7, ?? ) 0x81c0 _ctl
;

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

8
blk/634 Normal file
View File

@ -0,0 +1,8 @@
: _chk ( c --, check _sel range )
_sel C@ DUP 0x7f > IF 0x20 _sel C! THEN
0x20 < IF 0x7f _sel C! THEN ;
CREATE _ '0' C, ':' C, 'A' C, '[' C, 'a' C, 0xff C,
: _nxtcls
_sel @ _ BEGIN ( c a ) C@+ 2 PICK > UNTIL ( c a )
1- C@ SWAP DROP _sel !
;

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 )
_chk _sel C@ (emit) -1 XYPOS +!
( return whether any of the high 3 bits is low )
0xe0 AND 0xe0 <
;

9
blk/636 Normal file
View File

@ -0,0 +1,9 @@
: (key)
_next C@ IF _next C@ 0 _next C! EXIT THEN
BEGIN _updsel UNTIL
_prevstat C@
0x20 ( BUTC ) OVER AND NOT IF DROP _sel C@ EXIT THEN
0x40 ( BUTA ) AND NOT IF 0x8 ( BS ) EXIT THEN
( If not BUTC or BUTA, it has to be START )
0xd _next C! _sel C@
;

2
blk/637 Normal file
View File

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

Binary file not shown.

View File

@ -7,6 +7,9 @@ all: $(TARGET)
$(TARGET): xcomp.fs $(STAGE)
cat xcomp.fs | $(STAGE) > $@
os.sms: $(TARGET)
dd if=$(TARGET) bs=32752 conv=sync | cat - sega.bin > $@
$(EMUL):
$(MAKE) -C ${@:%/sms=%}

BIN
recipes/sms/sega.bin Normal file

Binary file not shown.

View File

@ -3,10 +3,14 @@
0xdd00 CONSTANT RS_ADDR
( Memory register at the end of RAM. Must not overwrite )
0xddca CONSTANT PS_ADDR
RAMSTART 0x70 + CONSTANT VDP_MEM
0xbf CONSTANT VDP_CTLPORT
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 )
@ -22,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!

View File

@ -19,8 +19,7 @@ emul: $(EMUL) $(TARGET)
$(EMUL) $(TARGET)
os.rom: $(TARGET)
cp $(TARGET) $@
truncate -s 1M $@
dd if=$(TARGET) bs=1M of=$@ conv=sync
os.8xu: os.rom
$(MKTIUPGRADE) -p -k keys/0A.key -d TI-84+ os.rom $@ 00