From 779b61f7c0592f37a8a98112623e9c0f499875de Mon Sep 17 00:00:00 2001 From: Martin Haye Date: Mon, 8 Aug 2016 08:09:46 -0700 Subject: [PATCH] Continued F8 refactoring. --- Platform/Apple/virtual/src/core/mem.s | 34 ++++++++++++------- Platform/Apple/virtual/src/include/mem.i | 27 +++++++++------ .../Apple/virtual/src/plasma/gameloop.pla | 16 ++++----- 3 files changed, 44 insertions(+), 33 deletions(-) diff --git a/Platform/Apple/virtual/src/core/mem.s b/Platform/Apple/virtual/src/core/mem.s index e6d0abe3..21acb525 100644 --- a/Platform/Apple/virtual/src/core/mem.s +++ b/Platform/Apple/virtual/src/core/mem.s @@ -399,11 +399,12 @@ loMemBegin: !pseudopc $800 { jmp __asmPlasm_bank2 ; Vectors for debug macros - jmp __iosaveROM - jmp __iorestLC + jmp __safeBell jmp __safeCout jmp __safePrbyte jmp __safeHome + jmp __safePrhex + jmp __safeRdkey jmp __writeStr jmp __prByte jmp __prSpace @@ -706,16 +707,28 @@ _prShared: !zone { jmp __iorestLC } +__safeBell: !zone { + jsr saveLCState + jsr ROM_bell + jmp restLCState +} + __safeCout: !zone { jsr saveLCState jsr ROM_cout jmp restLCState } -safePrhex: !zone { - jsr __iosaveROM +__safePrhex: !zone { + jsr saveLCState jsr ROM_prhex - jmp __iorestLC + jmp restLCState +} + +__safeRdkey: !zone { + jsr saveLCState + jsr ROM_rdkey + jmp restLCState } __prSpace: !zone { @@ -769,10 +782,7 @@ __crout: !zone { __waitKey: !zone { jsr __iosaveROM jsr ROM_rdkey - pha - jsr __iorestLC - pla - rts + jmp __iorestLC } ; Support for very compact abort in the case of internal errors. Prints @@ -1583,7 +1593,7 @@ aux_printMem: txa and #$F tax - jsr safePrhex + +safePrhex txa beq + lda #':' @@ -2342,7 +2352,7 @@ disk_finishLoad: !zone .debug1:+prStr : !text "Ld t=",0 pha lda resType - jsr safePrhex + +safePrhex +prSpace pla +prStr : !text "n=",0 @@ -2350,7 +2360,7 @@ disk_finishLoad: !zone +prStr : !text "aux=",0 pha lda isAuxCmd - jsr safePrhex + +safePrhex +prSpace pla rts diff --git a/Platform/Apple/virtual/src/include/mem.i b/Platform/Apple/virtual/src/include/mem.i index d4f8ad9e..66b85b9b 100644 --- a/Platform/Apple/virtual/src/include/mem.i +++ b/Platform/Apple/virtual/src/include/mem.i @@ -398,12 +398,13 @@ _asmPlasm = auxLoader+3 _asmPlasm_bank2 = _asmPlasm+3 ; Debug support routines (defined in core/mem.s) -_iosaveROM = _asmPlasm_bank2+3 -_iorestLC = _iosaveROM+3 -_safeCout = _iorestLC+3 +_safeBell = _asmPlasm_bank2+3 +_safeCout = _safeBell+3 _safePrbyte = _safeCout+3 _safeHome = _safePrbyte+3 -_writeStr = _safeHome+3 +_safePrhex = _safeHome+3 +_safeRdkey = _safePrhex+3 +_writeStr = _safeRdkey+3 _prByte = _writeStr+3 _prSpace = _prByte+3 _prWord = _prSpace+3 @@ -416,12 +417,8 @@ _internalErr = _waitKey+3 fixedRTS = _internalErr+3 ; Debug macros -!macro iosaveROM { - jsr _iosaveROM -} - -!macro iorestLC { - jsr _iorestLC +!macro safeBell { + jsr _safeBell } !macro safeCout { @@ -429,13 +426,21 @@ fixedRTS = _internalErr+3 } !macro safePrbyte { - jsr _safeCout + jsr _safePrbyte } !macro safeHome { jsr _safeHome } +!macro safePrhex { + jsr _safePrhex +} + +!macro safeRdkey { + jsr _safeRdkey +} + !macro prStr { jsr _writeStr } diff --git a/Platform/Apple/virtual/src/plasma/gameloop.pla b/Platform/Apple/virtual/src/plasma/gameloop.pla index 57225298..135eb4d7 100644 --- a/Platform/Apple/virtual/src/plasma/gameloop.pla +++ b/Platform/Apple/virtual/src/plasma/gameloop.pla @@ -503,7 +503,7 @@ end // Get a character from the keyboard export asm rdkey +asmPlasm 0 - +waitKey + +safeRdkey ldy #0 rts end @@ -550,8 +550,7 @@ end // Print a 16-bit hex value asm printHex +asmPlasm 1 - +prYA - rts + jmp _safePrhex end /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -574,22 +573,19 @@ end // Ring the bell export asm beep +asmPlasm 0 - +iosaveROM - jsr ROM_bell - jmp _iorestLC + +safeBell + rts end /////////////////////////////////////////////////////////////////////////////////////////////////// // Read a string from the keyboard, turn it into a PLASMA string and return a pointer to the string. asm readStr +asmPlasm 0 - +iosaveROM + bit setROM jsr ROM_getln1 + bit setLcRW+lcBank2 txa pha - +iorestLC - pla - pha beq + - lda inbuf-1,x and #$7F