Hydro's notes for C128 conversion (2012) This describes the original code and data of DIGIMASTER original V1.1j (and 1.1m) by Chris Brenner (c) 1993-1994 Most of the code was moved 'up' by $4000. So in the notes, if an address is $2423 (for example) on the C64 then it will probably be $6423 (bank 0) ON the C128. Some code gets shuffled or has patches added so look for comments like "(new $xxxx)" or " => $xxxx" Calls to BASIC ROM do the same as on C64 but naturally the ROM address is very different on C128 (not simply add $4000) The (non-Kernel) data has been moved quite a bit compared to C64. Bitmap moved from $e000 to $2000. Color moved from $d400 to $1c00. Charset moved from $d000 to $7c00. Sprites moved from $d800 to $0e00 Window buffer moved from $d900 to $8000. Audio data moved from $6cxx to $04xx (bank 1) Memory map C128 bank "Zero-Alt" ($ff03) $0000~008f digimaster/BASIC $0090~00fa kernel $00fb~0110 digimaster/BASIC $0111~03FF system ($200~280 gets code to playback data in bank 1) $0400~09ff unused (VIC text and BASIC stack during boot only) $0a00~0aff system $0b00~0dff unused $0e00~0f3f sprites $0f40~10ff unused (function key defs) $1100~12ff unused (BASIC control during boot only) $1300~1bff unused (reserved for device drivers) $1c00~1fff bitmap color $2000~3f3f bitmap pixels $3f40~3ff7 unused $3ff8~3fff vector IRQ code to RAM $4000~40xx BASIC startup code $41b0~43xx patches added for C128 version $4334~67b8 patched and moved code from C64 $67b9~6c5b moved data from C64 $6c5c~6c63 moved file header from C64 (see also bank 1) $6c64~6d0f mouse code from c64 (copied to $66bf if mouse selected) $6d10~7b0f unused $7b10~7b8f copy of zero page for quit $7bfa~7bff copy of CPU vectors during playback $7c00~7fff character set $8000~87ff? buffer bitmap for windows/menus $8000~cfff BASIC and Editor ROM $d000~dfff I/O $e000~ffff KERNAL and MMU bank 1 ($ff02) $0000~03ff Not available (common RAM from bank 0) $0400~040f unused $0410~0417 file header during load/save (copied to/from $6c5c in bank 0) $0418~fefe audio data $feff(or sooner) zero terminator $ff00~ffff MMU regs and interrupt dispatch LOAD"DIGIMASTER",8,1 (autostart) loads to $2a7~$30f it trashes vectors $300-30f, and starts $2a7 which blanks the screen, disables messages (twice), loads"0:DM" and then JMP $334 DM loads to $334~2c64 it loads BITMAP to $e000~ff3f it loads COLORMAP to $c400~c7e7 it loads SPRITEDATA to $c800~c97f (first 3 are arrow, #4 is 3char hbar, #5 is 1char vbar, #6 is 2char hbar) (they map to sprite pointers $20~25) it loads CHARMAP to $c000~c3ff (chars 0~$1f box drawing, $20~$7f ASCII) @0379 jsr $2302 (SEI, all RAM) $125e = copy .AX bytes from ($2b),y to ($2d),y (upward) copy $c400~c7ff to $d400 (color map) copy $c000~c3ff to $d000 (charmap) copy $c800~c8ff to $d800 (2/3 of sprites -> $60~$63) set sprite pointers @03d8 jsr $2319 (KERNAL) $0c->border, VBANK 3 matrix=$d400, bitmap=$e000 ($58) bitmap, screen visible, standard y-scroll sprites 0~2 on sprite 0 = yellow, 1 = orange, 3,4 = WHITE (??), 2 = black (into $38) @0418 sprite 4 = x-xpand movspr 0,32,56 (stupid) movspr 0~2,56,56 movspr 2,+0,+6 @044b $314 -> $27ed $26bf ->314, CLI $6d-> $2811 $80 -> $2c63 @046c jsr $2423 - init SID jsr $21d8 - clear graph array jsr $1f60 - graph to bitmap jsr $1948 - sign on message @0478 jsr $2344 - print start & end mem.offset ? @047b wait for button ($27f1) @0485 - hit test @04d4 - main menu click (x=1~3) @0502 - menu loop 0539 - item choosen, do command .A ($283e) @055c - play/sel.but loop 05af - play/sel.but choosen @05b7 - test in graph @05c4 - start graph selection @05dd - graph sel.loop @063d - test arrow X, .A = 0 ok, .X = graph x, .A = $ff off graph @0658 - highlight selection @0667 - graph highlight @06f0 - invert vline (bit .A), .X = x @0723 - .A = 2**(7-.A) @072f - range & play buttons ?0730 - do button @07b3 - toggle button animation @07d5 - invert color? pixels? @07eb - MENU load 0838 - limit size 0846 - load address 084f - set size in header based on endAddress ($ae), set term, regraph, jmp main loop @0881 - menu save 08c9 - scratch and rename 08d5 - error ? @08e6 - menu save as @0900 - menu save range @098f - menu about @0997 - menu quit @09ba - menu cut @09d5 - menu copy @09ee - menu erase @0a54 - menu paste insert 2b,2c -> end org => end after 2d,2e -> end after => end org 2f,30 -> end org (for insert at end) 2f,30 -> insert start 0af5 - no clip 0af8 - too big 0afe - load err @0b07 - menu paste over 2B,2C -> insert/start => swap 2d,2e -> org_end/clear => swap 0bb0~0bd7 => free *********** @0c1c - menu configuration @0c58 - menu backwards @0cb6 - menu volume 2d,2e = sel start (temp) 2b,2c = sel length 2d,2e = sel end 0d45 - divide .A by val@$2b, .X = quotient, $39 holds remainder (uflo) quotient -> $3d (negate if .Y flag) 0d6b - divide $2b,2c by val@$3a, .YX = quotient, $2b holds remainder (uflo) quotient -> $33,34 -> 2f,30 2b,2c = sel start => 2d,2e 0de5 - preReVolume (unsigned mangling) 0e17 - [$31] += [$3a]*[$3b] X = [$31] / +100 @0e3d - menu resample start -> 2b,c & 2d,e (new READ $2d, write $2f) 1st -> fe 0 -> fd old#cyc -> fb new#cyc -> fc (= old then 0eb2, < old then 0ec3, else... 0e7b) 0e7d = bump $2b, read next ($2b), break if Z call $222b, loop if Z 6c2b+0 -> ($2d), inc $2d ~ea0 update #cyc, calc new length from $2d 0eb2 zero tail, regraph, exit 0ebb mem.err 0ec3 check mem, scratch "sampleclip", open 8,u,8,"sampleclip,p" send dummy address ($2c5c -> 6c5c -> $0410) send header with new #cycles ($2c23) and 1st byte unaltered ($fe) 0f38 loop - bump $2b, read $2b and exit if zero call 222b (resample), tax send X bytes from table at $2c2b 0f69 load "0:sampleclip" (larger resample) @0f87 - menu loop range @0f8f - menu sample audio 0ff1 = set CIA timer start timer (pre sample), wait button pressed, stop timer 102c = wait button up @1087 - (pre)sample NMI routine @10ac - sample NMI routine @10eb start- @1102 start+ @111d play selection @1166 play all @1174 WIDTH- @118f width+ @11a8 : LOAD @11ad : close #8 @11b5 : change input to file# 8 @11ba : change output to file# 15 @11bf : return CLC if open file and read a byte ok (file exists); either way, close file @11d8 : scratch @1206 : rename temp to actual @1242 : CLC if open dir and read byte ok (device/disk exists); either way, close file @127f : Y=char row, X=char column, .A = len (or $80 for 7 rasters), $2b=> string @12e2 : Y=char row, X=char column, .A = len (or $80 both colors), $fb= color(s), paint row @131f : render menu @1386 : erase menu @13da : highlight main menu item @13e7 : set graphic pointers for 1st item in menu @142f : calc. menu next item bitmap address ? @1444 : un-higlight menu item ? ($f0) @1454 : hilight menu item ($61) @1489 : get current row (.A=$ff off menu, .A=16 top/off ?, X=A= index in menu) @14b8 : file dialog; .A = 0 load, A<> 0 save @155b : read directory @1583 : next dir.files @1594 : prune Seq/Prg loop @168a : wait user @16a0 : pick list or edit @16b1 ; pick list @1727 : begin edit @173e : edit loop @174b : key check loop @179d : cancel/return ? @17ad : delete char @17db : long branch ? (jmp $168a) @17de : button test @17f8 : button hit @1839 : change disk @1842 : swap 8/9 ? @186a : next set of files @1875 : restart dir ? @187b : ok [load/save] = copy to $2a22, clc, rts 1897 : dum call -> close 8 and 15 then read error channel, then display error# @189b : cancel = clear graph, close 8, sec, rts @18a3 : erase window and show dialog in .A (2*A->X, jmp $27d7,x) @18b8 : display disk error#, wait for click @18dc : "Out of Memory" message @1900 : "File Error" message @1924 : "Please set Range" message @1948 - sign on message @1990 - lda #12, rts ! @1993 - "Sample Rate" window 1a2a - choice made @1a82 - "Configuration" window 1b47 - choice made @1be7 - "Volume" window ??? ~1c7b - choice made @1d15 : "Please Wait" message @1d33 "Overwrite File?" prompt @1d81 : "Insert Disk" message box @1da2 : Y=char row, X=char column, .A = #rows ??, $39 => #columns ?? , window @1e5c : draw yes/no(A) box ? @1ea6 : draw radio button @1ee4 - draw less/greater button @1f60 - graph to bitmap @2010 : play! @20c6 : play raster irq -> ~60d8 @2135 : play timer nmi -> ~6140 >@2184 : wait border @218a : $fb,c = graph scale * .X (graph x ??), input .Y= ram pages used ??? .YX = $fb,c (# graph? address offset ???) @21d8 - set zero terminator, clear graph array if less than $100 bytes @2204 - animate yes/no click ? @2228 - toggle animation (jmp 07b3) @222b - resample 22D5 exit 22df : .A -> FAC -> ARG, $fb -> FAC, FAC = ARG / FAC, FAC -> ARG 22f2 : $fb - $fd -> FAC, FAC *= ARG, FAC -> long @2302 (SEI, all RAM) @230A = KERNAL, CLI @2312 = all RAM @2319 = KERNAL @2320 = no IO (all RAM) OR kill BASIC ROM @2327 = only IO -OR- enable BASIC ROM @232e : read serial and set carry if error (bug fix $ffcf) @233a : write serial and set carry if error (bug fix $ffd2) @2344 - print start and end ? mem.offset ? @2399 - clear bitmap (32 x 16 char area) @23be = clear matrix (32 x 16 char area) @23ef = wait button down, return X,Y = char column, row @241b = wait button up @2423 - init SID @2453 = .A(int) to string at $100 @2455 = .YA to string at $100 @247c save clip, return CLC okay @24f8 display error, validate disk, sec rts @2505 : validate disk @2523 : open 15,X,15 @2531 : close #15 @2539 : close 8 and 15 then read error channel, then display error# @2570 : prep num/nam for open 8,u,8,"0:dm.temp.save" @2582 : prep num/nam for open 8,u,8,"0:"... $2a1f/$2a22 @2598 : prep num/nam for open 8,ut,0,"0:editclip" @25ab : open 8,u,0,"0:$*" Size check @25be : 1e6/.A -> stack (new samples/sec), 1e6/$2c63 (org samples/sec) -> stack #sample bytes -> ARG stack -> FAC, FAC = ARG / FAC, FAC -> ARG (org seconds) stack -> FAC, FAC = FAC*ARG (new samples) FAC -> i32, i16+ 11,364, sec if i16 >= 52,992 *NEW* i16+= 0x418, sec if i16 >= 0xff00 @263e : * slowly set ARG = FAC = 1e6 * @265c = .YA = .A * 8, .x = .A @266d = .YA = .X * +10, .X = .A @2680 - .YA = .X * +40, .X = .A @2693 - .YA = .X * +320, .X = .A @26ab - add .YX to pointer at .A (wako!) @26bf - main IRQ head (JOYSTICK) 27ed = old vector 27f1 = fire/dir image 26c5 - do left/right 2813 = left/right speed 2814 = left/right acceleration 2817 = temp delta 273d - do up/down 2815 = up/down speed 2816 = up/down accel. 279c (end) @26C5 - (MOUSE) => 26bf 27d6 = old vector => 27ed 27fc = enable ? 27da = button image => 27f1 26e2 - do left/right 27fd = X potentiometer => 2813 2722 - do up/down 27fe = Y potentiometer => 2814 275c - do axis => 273f 27ff - new pot. (.A) => 2815 2800 - old pot. (.Y) => 2816 2785 (end) => 2768 --------------- data ------------------------ @279d~be array of [17] menu command addresses 279d~a8 File menu [6] 27a9~b4 Edit menu [6] 27b5~be S/FX menu [5] @27bf~ca array of [6] button command addresses 10eb start- 1102 start+ 111d play selection 1166 play all 1174 WIDTH- 118f width+ @27cb~d6? array of [6] file dialog command addresses 1839 #0 disk 1842 #1 device 186a #2 more 1875 #3 reread 187b #4 load/save 189b #5 cancel @27d7~ee? array of [12?] generic dialog command addresses #0 "Disk Error #" #1 "Out of memory" #2 "File Error" #3 "Please set Range" #4 copyright message #5 lda #12, rts (!!) #6 sample rate dialog #7 "Configuration" #8 "Change volume" #9 save #a scratch ??? delete and save ??? @27ef temp vector @2811 sample rate index (0,1,2 -> $52, $64, $80) @2812 loop playback (yes <> 0) @2818 current button 2818 command index 2819 char x left 281a pixel height / char width ? 281b colors ? @281c main button array[6*4] @2834~283d current menu 2834 = menu# ? 2835 = # items ? 2836 = ? 2837 = pixel left 2838 = pixel right 2839 = menu char width 283a = char left 283B = command base (even) 283c,d = string ??? address @283e ??? flag no selection @283f menu array (10 bytes each) 283f menu 1 -> 285d 2849 menu 2 -> 28c5 2853 menu 3 -> 2945 @285d menu1: load, save, save as, save range, about, quit @28c5 menu2: cut, copy, erase, paste over, paste insert, config @2945 menu3: volume, resample, backwards, loop range, sample audio @29ae device# [boot?] @29af device# [MAIN] @29b0 device# [temp] @29b1 load/save flag (0=load) @29c5 EOI ? @29c7 EDIT filename ? @2a33 ? @2a1f filename length @2a20 filename prefix "0:" @2a22~31? filename proper @2A33 edit len ? @2a34 edit filename @2a45 [10]file name(s) in directory @2ae5 [10]file len(s) in directory @2aef [10]file type(s) in dir. @2b05,6 drive error# (ascii) (part of message string) @2c22 yes/no response (0 = yes) @2c23 sample rate / $10 + 1 (6,7,9) for dialog @2c24 device# main for dialog @2c25 device# temp for dialog @2c26 ? @2c27 ? @2c2b [8/9] DFF header / JUNK @2c3b ? @2c57,8 = clip length @2c59 = sel start x @2c5a = sel end x -- file header -- @2c5c,d = sample size (min/default $100) @2c5d,e = samples in file [bug ?!] @2c5f = 0 @2C60 = "DFF" @2c63 = #cycles -- file data -- @2c64 ... end of memory or file = sample data ! irq to low ram -> sta $ff03, jmp $66bf ! 5f84 -> jsr 3ac, 3ac-> ldy #0, $2d->3b2, 3->3b4 (undo, #3b2->3ac, inc 3b4) !513f -> jsr 4317; add wait button ($641b) after fix common play ($60d8) to use FIRE / left-click NEW 41d8 patch reverse 41F0 patch paste insert 42A0 patch load $42c0 patch size in header (lo) $42c8 patch size in header (hi) 42d0 setup header at ($2b) and save samples at 6c2b 4317 patch volume 4381 PATCH save 4398 patch play 43b4 patch erase