Great work @Dbug!
The joystick utility will be very helpful and even more as part of the OSDK. What is the bug related to the C compiler?
About the OPEL's code: you found all "secrets" which I discovered (are there more?).
To summarize what I found as interesting:
1.
Merging machine code with BASIC - the trick for me was well known, but always the machine code is
after the BASIC, then DOKE at 156,157 ($9C,$9D - End of Basic pointer.) new higher address and next CSAVE will store to tape the whole area including BASIC and ASM code. But OPEL does DOKE #400 at 154,155 ($9A,$9B Start of Basic pointer.) and next CSAVE stores again the whole area. What make this code "exceptional" is that the saved program has the flag of BASIC
program and no matter that the start address is not #501 (but #400) when loaded the execution starts at #501 as any other "normal" BASIC program. This makes me think: why the heck Tangerine left the page 4 free and made BASIC start at page 5 (i.e. #501)? Is it possible that this weird OPEL's code is actually a good and even "standard" feature?
2.
Cross-page boundary indexing - using:
Code: Select all
9C03 A2 FC LDX #$FC
9C05 BD 04 02 LDA $0204,X
9C08 48 PHA
9C09 E8 INX
9C0A D0 F9 BNE $9C05
instead of the "normal":
Code: Select all
LDX #$00
LDA $0300,X
PHA
INX
CPX #$04
BNE ...
has 2 advantages - it's 2 bytes shorter and at end of the cycle you have set Z-flag and ZERO value in X which can be handy for the next operations. The same trick is used to access the byte tables:
Code: Select all
LDA f9B93,X ;300 DOKE #45E,AD-109
STA SYS_ICHAR ;The AS’CII code for the last key pressed (with top bit set).
LDA f9BB3,X ;300 DOKE #464,AD-77
STA VIA_PORTB
LDA f9BD3,X ;300 DOKE #46A,AD-45
STA VIA_PORTAH
Notice here the base address used for indexing
$9B93 but the table is actually placed at
$9C73:
Code: Select all
9C73 .BYT $55,$55,$55,$00,$55,$55,$00,$8B ; here $9C73 = $9B93,X (when $X >= E0)
.BYT $55,$00,$55,$88,$00,$8A,$89,$A0
.BYT $55,$55,$55,$00,$55,$55,$00,$8B
.BYT $55,$00,$55,$88,$00,$8A,$89,$AA
and to setup X register correctly we have:
Code: Select all
9748 09 E0 ORA #$E0
.....
9750 AA TAX
... crazy, right?
3.
Easy relocatable code - at #4E0 we have:
Code: Select all
04E0 A2 00 LDX #$00
04E2 BD 00 04 LDA $0400,X
04E5 9D 00 9C STA $9C00,X
04E8 9D 00 B8 STA $B800,X
04EB E8 INX
04EC E0 E0 CPX #$E0
04EE D0 F2 BNE $04E2
04F0 60 RTS
this moves the driver code from $400..$4DF simultaneously to $9C00 and $B800 by default. But if you change the BASIC variable
AD to (for instance) $5000 then the CALL#4E0 will move the driver code to $5000 and the (strange at first look) POKE's:
Code: Select all
300 DOKE #45E,AD-109:DOKE #464,AD-77:DOKE #46A,AD-45
will fix all absolute addressing to the new base.
4.
Other tiny goodies - in the "JOYSTICK CONTROL" progy we have detection of the ROM version:
IFPEEK(#FFF9)=1THEN Atmos ELSE Oric-1; and nice CSAVing as "JOY" tap file with modified key definition.
Well, sorry for the long post (I hope it's not boring) but I think it deserves this "waste" of time.
Be safe and Up the Orics!