From 04113c47254e287e690e301a848b7edadc0c90fb Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sun, 30 Jan 2022 15:50:54 -0500 Subject: [PATCH] Rom 1 _InstallCDA call clobbers some direct page locations. This is fixed in ROM 3 (or via the TS patches if you boot GS/OS). Workaround it by switching to DPAGE 0. Also, allocate memory (since I originally thought that might be relevant). --- vt.equ.S | 2 ++ vt100.cda.S | 12 +++++++++++ vt100.main.S | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) diff --git a/vt.equ.S b/vt.equ.S index 8fc9caa..fa23add 100644 --- a/vt.equ.S +++ b/vt.equ.S @@ -93,6 +93,8 @@ read_q_tail ds 2 write_q_head ds 2 write_q_tail ds 2 +master_id ds 2 + do *>256 err "too big" fin diff --git a/vt100.cda.S b/vt100.cda.S index 281f65c..7cede82 100644 --- a/vt100.cda.S +++ b/vt100.cda.S @@ -37,8 +37,20 @@ ptr ds 2 init_cda ent php rep #$30 + +* +* rom 1 IIgs InstallCDA clobbers $3c-$43 on the direct page +* + + phd + pea #0 + pld + psl #handle _InstallCDA + + pld + plp rts diff --git a/vt100.main.S b/vt100.main.S index ef514bd..e0de479 100644 --- a/vt100.main.S +++ b/vt100.main.S @@ -4,6 +4,8 @@ xc xc + tbx on ; qasm + mx %11 use vt.equ use apple2gs.equ @@ -62,6 +64,9 @@ init sta SETALTCHAR rep #$30 + jsr init_mem + + ldx #254 :zloop stz 0,x dex @@ -120,6 +125,60 @@ init jsr init_cda rts +init_mem +* +* see prodos technote #27 +* +* _InstallCDA uses the memory manager ; otherwise I wouldn't bother +* This is here to prevent MM from stomping on our memory. +* + + mx %00 + + stz master_id + _TLStartUp + pha + _MMStartUp + pla + bcs :p8 + rts +:p8 + _MTStartUp + pea #0 + pea #$1000 + _GetNewID + pla + sta master_id + +* bank 0 + pha + pha + pea #$0000 + pea #$b800 + pei master_id + pea #$c013 + pea #0000 + pea #0800 + _NewHandle + pla + pla + +* bank 1 + pha + pha + pea #$0000 + pea #$b800 + pei master_id + pea #$c013 + pea #$0001 + pea #$0800 + _NewHandle + pla + pla + + rts + + reset ent mx %11 php