|
Post by VDC 8x2 on May 3, 2015 17:39:08 GMT
What is the proper way to load some code from disk into any bank on c128?
On my linker it keeps doing a cpu jam in vice.
|
|
|
Post by cbmguy on May 5, 2015 20:31:25 GMT
Here's a snippet from my file/drive management source code I'm writing. Cheers, c
; stashbyte =* ; save a byte in bank 0 ldx #$3f stx mmu ; go to bank 0 sta (p2),y ; save data ldx #0 stx mmu ; back to default bank rts ; and return ; getbyte =* ; get a byte from bank 0 ldx #$3f stx mmu ; go to bank 0 lda (p2),y ; get data ldx #0 stx mmu ; back to default bank rts ; and return ;
|
|
|
Post by hydrophilic on May 20, 2015 7:08:32 GMT
Wow, cbmguy, you continue to amaze me with your code... I only *half* understand it
When I want KERNAL compatibility, I do this:
lda #fileNum ;Logical (arbitrary/unused) file# ldx #devNum ;Physical device# (usually 8~11) ldy #0 ;Secondary address (use file "load address") jsr $ffba ;set LFS (logical, physical, secondary) lda #(endName-startName) ;length of filename [might need +1] ldx # < startName ;low byte of filename ldy # > startName ;high byte of filename jsr $ffbd ;set Name ; C128 specific lda # dataBank ;BANK # 0~15 (for loaded data) ldx # nameBank ;BANK # 0~15 (of filename) jsr $ff68 ;SETBANK ; all CBMs... lda # 0 ;load (not verify) ldx #customAdrs ;(low) ldy #customAdrs ;(high) jsr $ffd5 ;load/verify
At the very end (call $ffd5), the "custom load Address" (X and Y registers) are ignored (uses first 2 bytes of file instead), unless you give a non-zero value of Y at the beginning (call $ffba)
Sorry if that is not clear... but I use it many C128 projects, and it works... ask for details / clarification...
|
|
|
Post by VDC 8x2 on May 20, 2015 13:58:32 GMT
Is the bank stuff using normal bank numbers or is it using the raw MMUCR bits?
|
|
|
Post by cbmguy on May 22, 2015 18:22:07 GMT
lol so sorry. I knew the answer and got excited--I was just working on that solution just the day before. That routine is used with the burst protocol which isn't presented in that snippet--when data is entering, I count it (y register) and then I stash the byte away using the stashbyte rountine. In my case, I stash the byte in bank 0 and then continue on with the burst data stream and y is the offset. You can change the value of the x register to Bank 1 ram using the appropriate byte for the mmu--I don't know those just off the top of my head atm. p2 refers to a zero page indirect pointer (incremented each time y rolls to 0). To get the byte, it's the same thing, but one is loading the register with the data and the stream of data is being sent to the drive. All performed sequentially--it works for all file types (except maybe rel)
|
|
|
Post by hydrophilic on May 26, 2015 5:37:57 GMT
In the KERNAL (compatible) code that I posted, the values are "standard" banks 0~15... not MMU values of 0~255
Hope that helps?!
|
|