Login
Back to forumSee the full topicGo to last reply

Posted By

GeorgeHug
on 2021-11-25
19:10:36
 Re: Error in Plus/4 Kernal Rom

In case anybody might need it, I decided to write replacement IRQ servicing code that bypasses the error in the kernel rom. It duplicates the first part of the IRQ servicing routine, does the ACIA stuff, then jumps back to ROM for all the other IRQ stuff. There's a BASIC loader that installs the new code (120 bytes) into the tape buffer (but it could go anywhere below $8000). In addition to fixing the BEQ problem, I took out all the xon/xoff software flow control code, which I think is useless. I don't have a CBM machine anymore, so I have no way to test the new code. Anyway, this might be an easier fix than flashing a new rom.

I'll list the BASIC program and the source code for the ML portion below. If anyone wants the actual .PRG, it can be found in my Github CBM repo:

https://github.com/gbhug5a/My_CBM_stuff

10 rem this code bypasses the "beq" bug
12 rem in the +4's irq acia received-
14 rem byte routine, and eliminates the
16 rem xon/xoff software flow control
18 rem code in both xmit and receive.
20 rem the irq service routine vector
22 rem ($0314) normally points to $ce0e.
24 rem this code duplicates that code up
26 rem to the acia, fixes that, then
28 rem jumps back into rom. the code is
30 rem poked into the cassette buffer at
32 rem $0333, but can be placed anywhere
34 rem visible in ram when kernel and
36 rem basic roms are banked in. sys
38 rem to the first byte to take over
40 rem $0314. no need to re-assemble for
42 rem a different location. the code
44 rem detects where it has been placed.
46 rem sys (first byte + 26) to restore
48 rem the the $0314 vector to $ce0e.
100 cb = 819
110 for i = 0 to 119
120 read a
130 poke cb+i,a
140 next
150 sys cb
160 v= (peek(789)*256) + peek(788)
170 print "irq ram vector now";v
180 data 120,32,85,252,186,202,189,0
190 data 1,24,105,36,141,20,3,232
200 data 189,0,1,105,0,141,21,3
210 data 88,96,120,169,14,141,20,3
220 data 169,206,141,21,3,88,96,173
230 data 9,255,41,2,240,3,32,96
240 data 206,44,216,7,16,63,173,1
250 data 253,141,212,7,16,55,173,212
260 data 7,41,8,240,24,173,212,7
270 data 41,247,141,212,7,173,0,253
280 data 141,213,7,173,211,7,201,63
290 data 240,3,32,220,234,173,212,7
300 data 41,16,240,17,173,16,253,41
310 data 2,240,10,162,0,44,206,7
320 data 16,3,32,131,234,76,43,206

.6502

;code to bypass error in +4 acia irq receive-byte routine,
;and eliminate xon/xoff software flow control for
;transmit and receive.

.org $0333
;object code can be moved anywhere
; without reassembly
;sys entry to set irq vector to newirq
;sys restore (entry + 26) to restore
; default vector

entry:

sei
jsr $fc55 ;just rts there
tsx ;pc now in stack
dex
lda $0100,x
clc
adc #(newirq - entry - 3) ;point to newirq
sta $0314
inx
lda $0100,x
adc #0
sta $0315 ;irq vector now newirq
cli
rts ;return from sys

restore: ;restore = entry + 26

sei ;restore vector to $ce0e
lda #$0e
sta $0314
lda #$ce
sta $0315
cli
rts

newirq: ;$035a (858) if entry = $0333

lda $ff09 ;not related to acia
and #$02
beq checkacia
jsr $ce60

checkacia:

bit $07d8 ;acia present?
bpl backtorom
lda $fd01 ;read status reg
sta $07d4 ;save status reg
bpl backtorom ;bit 7 set if acia triggered irq

receive:

lda $07d4 ;new byte received?
and #$08
beq transmit
lda $07d4
and #$f7
sta $07d4
lda $fd00 ;new byte
sta $07d5

lda $07d3 ;number of bytes in queue
cmp #$3f
beq transmit ;discard byte if full

jsr $eadc ;add new byte to input queue

transmit:

lda $07d4
and #$10 ;transmit buffer empty?
beq backtorom
lda $fd10 ;pin k of user port = cts
and #$02
beq backtorom ;modem says don't send
ldx #$00
bit $07ce ;anything to send?
bpl backtorom
jsr $ea83 ;send it

backtorom:

jmp $ce2b ;acia done, continue rest of irq



Back to top


Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon