Post by jmpff3d on Nov 17, 2018 14:21:47 GMT
Available at csdb.dk/release/?id=171583
Ice.128 v0.3 (ROM modifications) by XmikeX - 17 November 2018 - a work in progress !
**
This ROM modification adds the following to your Commodore 128; some mods may not work under all circumstances.
ROMs modified : basiclo, basichi, kernal - no internal / external function ROMs needed !
: No nationalized roms are involved, sorry (too esoteric) !
~~~~ Features ~~~~
ICE128 : The Alt-RAM Block 64mode Poor Man's Freezer !
SKIPCART128 : Integrates the Skipcart128 mod which allows you to choose whether or not C-64 Cartrige boots.
REU Unlimited : BASIC commands involving the REU can now use all REU banks, the entire 16 MB REU potential !
Key Expansion : RUN/STOP and HELP have been added to the redefinable key command and key list
New EasterEgg : Invoke with SYS32800,123,45,6 - tiny 'splash' screen of sorts !
Z80 ML Extension: ZASS (Z80) extension for 128's ML Monitor, by Michael Uemminghaus
Assemble in Z80 mnemonics * 1300 .rst 00h
Disassemble in Z80 mnemonics z 1300 1305
*** ZASS was CRUNCHED by Christopher Jam's TINYCRUNCH and uncrunched with superfast tc uncruncher! Thanks, cjam! ***
TERMinl : Simple Userport terminal, baudrate setting @ $005a
: Invoke with SYS 64628,2,10,0 (function key F4). In this example, 2 is the dummy channel/device
number, which always defaults to 2 in the routine. The 10,0 are the baudrate settings (1200 baud here).
IOINIT defaults to no parity, full duplex, 3-line, 1-stop bit, 8-bit words.
~~~~ new BASIC Commands, ICE and ZMON ~~~~
ICE : Alt-RAM C-64 freezer function, setup c64-mode in alt-ramblock for data-snapshot via reset back to 128mode
ZMON : invokes the MONITOR with the ZASS Z80 ML extension in place.
** Changes from CBM (c) 1986 AD Commodore 128 ROMs listed below **
------------------------------------------------------------------
; BASICLO ROM modications
***
$46A9 ; command table patching,
>f46a9 54 4d 4f ce 53 54 41 53:zmoNstas ; replace quiT with zmoN
>f46b9 53 57 41 d0 49 43 c5 46:swaPicEf ; replace ofF with icE
$47C6
>f47c6 d3 fc 1e aa 00 00 23 aa ; changed ZMON command JSR pointer to (ZMON routine) at $fcd4 minus one.
>f47d2 48 cf b2 77 c3 77 65 8c ; changed ICE command JSR pointer to (ICE routine) at $cf49 minus one.
>f478a 09 61 e4 bf c8 6b 45 70 ; changed MONITOR JSR pointer to (IRQ vector reset, then jmp monitor) at $bfe5 minus one.
$4846
>f4846 ff ff ff ff ff ; removed the ?UNIMPLEMENTED COMMAND routine
$4A64
>f4a64 ff ff ff ff ff ff ff ff ; removed the table entry for ?UNIMPLEMENTED COMMAND
>f4a6c ff ff ff ff ff ff ff ff
>f4a74 ff ff ff ff ff 46 49 4c
$60E4 ; expanded the range of editable function keys
. f60e4 ca dex
. f60e5 e0 0a cpx #$0a ; changed from #$08, allows manipulation of all ten function keys, instead of eight.
. f60e7 90 03 bcc $60ec
$617C ; expanded the range of editable function keys
. f617c a6 77 ldx $77
. f617e e0 0a cpx #$0a ; changed from #$08, allows manipulation of all ten function keys, instead of eight.
. f6180 d0 a3 bne $6125
; $63F5 ; replaced c128 author signatures with ...
. f63f5 20 7d ff jsr $ff7d ; JPRIMM kludge display cleanup of forced READY. prompt by ZASS
>f63f5 20 7d ff 0d 5a 4d 4f 4e ; "ZMON IS"
>f63fd 20 49 53 20 1b 51 00
. f6404 60 rts
; $7ED9 to $7FFB ; crunched zass data
; $7FC0 ; removed commodore (c) tags
; BASICHI ROM modifications
***
; $AA53 ; removed all REU-bank limitations from BASIC.
. faa53 0c SKW ; SKIP-WORD, absolute addressing (illegal op 0C) . 4 cycles, saves us 2 cycles here.
. faa54 ea nop ; originally cpx #$10 | bcs $aa65 -- this limited REU banks from 0 to 15.
. faa55 ea nop ; by removing this check on X, all 0-255 expansion REU banks are available from BASIC.
; e.g., stash 1024,1024,0,255
. faa56 ea nop ; SKIP-WORD continues here
; $AA81 to $AE63 ; crunched zass data
; $AE64 ; replacing the ol' EasterEgg message ( SYS 32800,123,45,6 ) !
; easteregger script, included in ice128 companion .d64
10 rem this program reads easteregg from ROM, decrypts to plaintext, saves to mem at b1-$1300 & dumps egg as hexbyte strings
20 bank15:lc=4863:fori=1to155:x=i:y=peek(44643+i):x=xor(x,y):a=xor(y,x):y=123:x=xor(x,y):y=0:a=xor(y,x):rem y=0 for plaintext
30 printchr$(x);:bank1:pokelc+i,a:bank15:nexti:print:print
40 a$="":bank1:fori=1to155:cc=cc+1:x=peek(lc+i):x$=right$(hex$(x),2)
50 print using "##";x$;:next
60 bank15:print:end
; hexstring output from BASIC program above can be fed into my easteregg patcher,
; available as a nodeJS script at - https://csdb.dk/release/?id=170660
; after you feed it the raw uncrypted hexbytes, this script will generate a new basichi ROM
; for you with the hexbytes crypted and patched in the proper spot,
raw uncrypted hexbytes of easteregg replacement, manually edited at $1300 for (in)convenience
>f1300 93 0e 9f ec b8 b8 b8 b8:...LXXXX
>f1308 b8 b8 b8 b8 b8 b8 b8 b8:XXXXXXXX
>f1310 b8 b8 b8 b8 b8 b8 b8 9a:XXXXXXX.
>f1318 bf 0d 9f a1 c9 c3 c5 20:...AICE
>f1320 56 30 2e 33 20 20 20 20:v0.3
>f1328 20 96 d8 4d 49 4b 45 d8: .XmikeX
>f1330 0d 9f a1 20 20 20 31 37:..A 17
>f1338 20 4e 4f 56 20 32 30 31: nov 201
>f1340 38 0d 9f a1 0d 9f a1 12:8..A..A.
>f1348 c9 c3 c5 20 c1 4c 54 2d:ICE Alt-
>f1350 d2 c1 cd 20 c6 52 45 45:RAM Free
>f1358 5a 45 52 92 0d 9f a1 12:zer...A.
>f1360 da cd cf ce 20 cd cc 92:ZMON ML.
>f1368 0d 9f a1 0d 9f a1 9e 41:..A..A.a
>f1370 4e 44 20 4f 54 48 45 52:nd other
>f1378 20 4d 49 4e 4f 52 20 45: minor e
>f1380 4e 48 41 4e 43 45 4d 45:nhanceme
>f1388 4e 54 53 92 0d 9f a1 0d:nts...A.
>f1390 9f a1 c3 d3 c4 42 0d 9a:.ACSDb..
>f1398 bf 99 0d 00 00 00 00 00:........
these hexbytes above are as follows, seen in series:
930e9fecb8b8b8b8b8b8b8b8b8b8b8b8b8b8b8b8b8b8b89abf0d9fa1c9c3c52056302e33202020202096d84d494b45d80d9fa12020203137204e4f5620323031380d9fa10d9fa112c9c3c520c14c542dd2c1cd20c65245455a4552920d9fa112dacdcfce20cdcc920d9fa10d9fa19e414e44204f54484552204d494e4f5220454e48414e43454d454e5453920d9fa10d9fa1c3d3c4420d9abf990d
starting at $ae64 they are crypted into the following series of hexbytes, replacing the original easteregg in rom
e977e793c6c5c4cbcac9c8cfcecdccd3d2d1d0d7d6d5d4f9dd6cffc6afa6a17b0c69766c7e7d7c7372c7881a1f1e119347d6e96f6e6d7d74620f0f116677740a0234a79e33a29d21fbf2f517f7796006f8e8e50fe87f6966786472b52bba8509c0d4d7d13ed0d0811f8eb11a89b48a4a444d28405a454951224c4949495724beb4b1b9b1bdb8b1b6bca5a365fb6a55e675482b3c2aafe1795d78ed
; $AFA8 to $AFFF ; crunched zass data
; $BB72 to $BFE4 ; crunched zass data
; $BFC0 ; removed commodore (c) tags
; $BFE5 ; restore normal irq vector when routine monitor command is invoked
. fbfe5 78 sei
. fbfe6 a9 65 lda #$65
. fbfe8 8d 14 03 sta $0314
. fbfeb a9 fa lda #$fa
. fbfed 8d 15 03 sta $0315
. fbff0 58 cli
. fbff1 4c 00 b0 jmp $b000
; KERNAL ROM modifications
***
; $CEA8 ; new table function key definitions .. must not exceed 246 bytes
; $CF19
; ** skipcart128 ** .. 8502 kernalside
. fcf19 ad 05 d5 lda $d505 ; consult with the MMU BitSwitch Guide ( https://pastebin.com/Wh2EKdwt )
. fcf1c 29 30 and #$30 ; testing for /GAME and /EXROM from cart port
. fcf1e c9 30 cmp #$30
. fcf20 f0 21 beq $cf43 ; if result from and/cmp is zero, then no 64 cart present, branch to c128-mode init
. fcf22 20 84 ff jsr $ff84 ; kernal JIOINIT routine
. fcf25 20 87 ff jsr $ff87 ; kernal JRAMTAS routine
. fcf28 20 8a ff jsr $ff8a ; kernal JRESTOR routine
. fcf2b 20 81 ff jsr $ff81 ; kernal JCINT routine
. fcf2e a2 00 ldx #$00
. fcf30 bd ca fe lda $feca,x ; collect data at $feca for printout by $ffd2 kernal BSOUT routine
; will be replaced by jsr to JPRIMM
. fcf33 f0 06 beq $cf3b
. fcf35 20 d2 ff jsr $ffd2 ; prints out the data from $fe93 onwards
. fcf38 e8 inx
. fcf39 d0 f5 bne $cf30
. fcf3b 58 cli
. fcf3c 20 cf ff jsr $ffcf ; re-enable IRQs - needed for keyboard input @ BASIN routine ($ffcf)
. fcf3f c9 59 cmp #$59 ; "y" from keyboard .. BASIN will accept "y" followed by other chars.. so "yes" will work
. fcf41 f0 03 beq $cf46 ; branch to c64-mode jump on at least "y"
. fcf43 4c 6b e2 jmp $e26b ; init 128 mode below .. fallthrough from top or keyboard input something other than y
. fcf46 4c 4b e2 jmp $e24b ; init c64 mode below .. keyboard input was at least y
[...]
. fd052 18 05 jr $0059 ; Z80 bootrom - skip c64-mode switch code, only z80 can see this segment (at $0052)
. fe242 20 9e cf jsr $cf19 ; 8502 kernalside, jump straight into skipcart128 mod code on bootup
. fe245 ea nop
. fe246 ea nop
. fe247 ea nop
. fe248 ea nop
. fe249 ea nop
. fe24a ea nop
[...]
; $CF49
; ICE Alt-RAM Freezer ; setup code for c-128 as c-64 freezer option, MMU config, and switch to 64mode.
. fcf49 78 sei ; disable IRQs
. fcf4a a2 00 ldx #$00
. fcf4c bd 93 fe lda $fe93,x ; collect data at $fe93 for printout by $ffd2 kernal BSOUT routine
; will be replaced by jsr to JPRIMM
. fcf4f f0 06 beq $cf57
. fcf51 20 d2 ff jsr $ffd2 ; prints out the data from $fe93 onwards
. fcf54 e8 inx
. fcf55 d0 f5 bne $cf4c
. fcf57 58 cli ; re-enable IRQs - needed for keyboard input @ BASIN routine ($ffcf)
. fcf58 20 cf ff jsr $ffcf ; BASIN routine for input, it waits for keyboard input and returns value in accumulator
. fcf5b c9 59 cmp #$59 ; "y" from keyboard .. BASIN will accept "y" followed by other chars.. so "yes" will work
. fcf5d f0 01 beq $cf60
. fcf5f 60 rts ; return from subroutine if user-input is anything but "y"...etc
. fcf60 78 sei ; disable IRQs out of paranoia - prepare 64mode with new MMU rambank freezer configuration
. fcf61 a9 40 lda #$40 ; consult with the MMU BitSwitch Guide
. fcf63 8d 00 ff sta $ff00 ; http://c-128.freeforums.net/thread/638/mmu-bitswitch-guide
. fcf66 a2 01 ldx #$01 ; for this segment
. fcf68 8e 0a d5 stx $d50a
. fcf6b 8e 09 d5 stx $d509
. fcf6e 8e 08 d5 stx $d508
. fcf71 ca dex
. fcf72 8e 07 d5 stx $d507
. fcf75 8d 06 d5 sta $d506
. fcf78 4c 4b e2 jmp $e24b ; jump to 64mode !
; $CF9E
. fcf9e a9 00 lda #$00 ; $1cxx cleanup routine for clean BASIC start
. fcfa0 a2 ff ldx #$ff
. fcfa2 9d 00 1c sta $1c00,x
. fcfa5 ca dex
. fcfa6 e0 ff cpx #$ff ; for underflow to zero out $1c00
. fcfa8 d0 f8 bne $cfa2
. fcfaa 60 rts
; $CFC0 ; removed commodore (c) tags
; $FC74
* = $fc74
TERMinl:
stx $5a ; stash X register from SYS call (baud byte)
sty $5b ; stash Y register from SYS call (baud byte)
lda #$02 ; same as OPEN 2,2,2 in BASIC, override A register from SYS call
tax
tay
jsr $ffba ; kernal SETLFS routine
lda #$02 ; call up logical file #2 again
ldx #$5a ; tell the kernal routines that the
ldy #$00 ; baudrate data starts at $005a
jsr $ffbd ; kernal SETNAM routine
jsr $ffc0 ; kernal OPEN routine
jsr $fe4f ; jsr to text string which jsrs to kernal (JPRIMM $ff7d) for blocktext output
nops ; dummy nops for testing
loop2:
jsr $ffb7 ; kernal READSS routine
and #$08 ; checks for status bit 3 being set
bne loop3: ; if yes, the character was not valid
ldx #$02
jsr $ffc6 ; kernal CHKIN routine
jsr $ffe4 ; kernal GETIN routine (from device 2)
jsr $ffd2 ; kernal BSOUT routine (to screen)
loop3:
jsr $ffcc ; kernal CLRCH routine
jsr $ffe4 ; kernal GETIN routine (from keyboard)
beq loop2: ; branch back if no key was pressed
cmp #$1b ; check for ESC key from GETIN
beq escape: ; if ESC key then jump to exit segment
pha ; store GETIN character to stack
jsr $ffd2 ; kernal BSOUT routine (to screen)
ldx #$02
jsr $ffc9 ; kernal CKOUT routine
pla ; retrieve GETIN character from stack
jsr $ffd2 ; kernal BSOUT routine (to device 2)
jsr $ffcc ; kernal CLRCH
beq loop2: ; branch back for another character
escape:
lda #$02 ; exit segment
jsr $ffc3 ; kernal CLOSE routine, close logical file #2
lda #$00
sta $5a
sta $5b ; clear zp
rts ; return from subroutine
; $FCD4 ; knitter copier - reassembles ZASS from fragments inside ROMs
* = $fcd4
knitter:
sei
ldx #$00
stx $59 ; table-indexpointer
stx $5f ; kernalcopy counter
kernalcopy:
ldx $59 ; table-indexpointer
lda $fdc0,x
sta $5a ; lowbyte read
lda $fdc1,x
sta $5b ; highbyte read
lda $fdc2,x
sta $5c ; lowbyte write
lda $fdc3,x
sta $5d ; highbyte write
lda $fdc4,x
sta $5e ; new copysegment value from table
inc $59 ; increment the table-indexpointer
inc $59 ;
inc $59 ;
inc $59 ;
inc $59 ; by +5
ldy #$00 ; clear offset for read/write
loop:
lda ($5a),y ; start address + y offset
sta ($5c),y ; destination address + offset
iny
cpy $5e ; copysegment value
bne loop:
inc $5f ; kernalcopy counter
lda $5f
cmp #$16 ; 23 loops
bne kernalcopy:
; $FD13, tinycrunch's uncruncher, courtesy Christopher Jam
* = $fd13
tinycrunch:
lda #$ff
sta $5a
lda #$1f ; destination of uncrunched data : start address minus one - $1FFF
sta $5b
lda #$00
sta $5c
lda #$13 ; location of crunched data - $1300
sta $5d
bne laxjam:
quit:
lda #$00
ldx #$06
zpclear:
sta $59,x
dex
bpl zpclear:
jsr $fdf7
jsr $cf9e ; jsr $1cxx cleanup routine for clean BASIC start - future plan to relocate ZASS to other mem location
jsr $2d00 ; jsr to start of ZASS code (by Michael Uemminghaus), his code SEI/CLIs after uncrunching
jsr $63f5 ; screen display kludge cleanup to accommodate forced READY. prompt by ZASS
rts
iny1:
iny
lda ($5c),y
sta ($5a),y
dex
bmi iny1:
tya
pha
clc
bigloop:
adc $5a
sta $5a
bcc defjam:
inc $5b
defjam:
pla
sec
adc $5c
sta $5c
bcc laxjam:
inc $5d
laxjam:
ldy #$00
b3 ??? ; lax ($5c),y
5c ???
beq quit:
asl
bcc iny2:
bpl iny1:
ldx #$03
f0 ; legal skipbyte by BEQ proxy #$f0
iny2:
iny
lda ($5c),y
adc $5a
sta $5e
txa
ora #$fc
adc $5b
sta $5f
tya
pha
ldy #$01
lda ($5e),y
sta ($5a),y
iny3:
iny
lda ($5e),y
sta ($5a),y
txa
cb ??? ; sbx #$04
04 ???
bpl iny3:
tya
bcc bigloop:
; $FD89 ; knitter's very inefficient (but human-readable) copytable .. great for debugging !
read write
; basiclo $7ED9 to $7FFB Offset
d9 7e 00 13 27
00 7f 27 13 d9
d9 7f 00 14 23
; basichi $AA81 to $AE63
81 aa 23 14 7f
00 ab a2 14 5f
5f ab 01 15 a1
00 ac a2 15 5f
5f ac 01 16 a1
00 ad a2 16 5f
5f ad 01 17 a1
00 ae a2 17 5f
5f ae 01 18 04
; basichi $AFA8 to $AFFF
a8 af 05 18 58
; basichi $BB72 to $BFE4
72 bb 5d 18 8e
00 bc eb 18 15
15 bc 00 19 eb
00 bd eb 19 15
15 bd 00 1a eb
00 be eb 1a 15
15 be 00 1b eb
00 bf eb 1b 15
15 bf 00 1c cf
; $FDF7 ; zmon/zass startup message
; $FE4F ; chardata for JPRIMM and BSOUT