mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-26 20:18:06 +11:00
Compare commits
9 Commits
db9885b8cf
...
f2817870aa
Author | SHA1 | Date | |
---|---|---|---|
|
f2817870aa | ||
|
7ceff6144c | ||
|
b6c039589f | ||
|
aad713c477 | ||
|
fdea069544 | ||
|
ebc70be8e8 | ||
|
852c775b5b | ||
|
f9a8e6f180 | ||
|
1597f1e131 |
4
blk/081
4
blk/081
@ -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
|
||||
|
4
blk/083
4
blk/083
@ -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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
1
blk/393
1
blk/393
@ -3,7 +3,6 @@
|
||||
: HERE 0x04 RAM+ ;
|
||||
: CURRENT* 0x51 RAM+ ;
|
||||
: CURRENT CURRENT* @ ;
|
||||
: XYPOS 0x40 RAM+ ;
|
||||
|
||||
( w -- a f )
|
||||
: FIND CURRENT @ SWAP _find ;
|
||||
|
4
blk/427
4
blk/427
@ -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
12
blk/428
@ -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 ;
|
||||
|
2
blk/622
2
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
|
||||
|
1
blk/623
1
blk/623
@ -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
17
blk/627
@ -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 ! ;
|
||||
|
1
blk/628
1
blk/628
@ -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
16
blk/630
Normal 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
6
blk/631
Normal 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
12
blk/632
Normal 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
15
blk/633
Normal 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
8
blk/634
Normal 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
13
blk/635
Normal 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
9
blk/636
Normal 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@
|
||||
;
|
BIN
emul/forth.bin
BIN
emul/forth.bin
Binary file not shown.
@ -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
BIN
recipes/sms/sega.bin
Normal file
Binary file not shown.
@ -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!
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user