|
Post by bjonte on Mar 4, 2021 16:28:20 GMT
Is there any way too keep basic in, and kernal, while possible storing code from $A000-$BFFF, $8000-$9FFF? Well, BASIC owns RAM from $1c00 to $ff00 so if the program grows your code could be overrwritten. If you know it won’t happen you can use memory where you want in that range plus the small gap in the last page. There’s some ROM code copied to RAM high up, I don’t remember exactly where, which you have to avoid also. But you should be able to simply tell the MMU that you want RAM instead of BASIC and Kernal, run the code and turn on BASIC and Kernal again. You can just toggle BASIC if you keep your code below $e000. I/O registers is usually best to leave turned on unless you really need the memory at $d000-$dfff.
|
|
|
Post by stiggity on Mar 5, 2021 19:22:14 GMT
BJONTE: Nice!!! Good news.. thanks for the reply. I know doing a little research would more than likely come up with an answer.. on the 64 (which were NOT dealing with) BASIC ROM is $A000-$BFFF and the directional register $01 like store a #$37 into $01 and basic rom and kernal and banked out.. Its been a year since I played on the 64.. but yes, u can bank kernal/IO/BASIC in/out (I was using common ram handlers, and it was all working) but where is BASIC ROM on the 128? I was banking kernal $E000-$FFFF on the 64, and had it working, alright. If I could come up with, yet another, down & dirty BASIC ROM bank out, I believe that's referred to as, heaven!
|
|
|
Post by wendling on Mar 9, 2021 11:37:13 GMT
Stiggity: To use ROM-subroutines when your programm runs in the RAM below, you have to do the jsr to the ROM-subroutine at a memory location that is not covered by that ROM. Below $4000 there is no ROM, turning on ROM there is save. For example: to print a text when your programm runs in RAM at $0c000 (under the screen editor/kernal): start: $c000 ldx #$00 L1: lda text,x beq done jsr $1400; normally you use jsr $ffd2 but the kernal is switched off. inx bne L1 done: rts text: romramtest,0 start: $1400; at $1400 it is save to turn the kernal on. jsr savconfromon; save your configuration and switch on all roms jsr $ffd2; rom subroutine you want to execute jmp rstconf; restore your configuration savconfromon: pha; save reg a lda $ff00 sta savc; save configuration lda #$00 sta $ff00; turn on all ROMs pla; restore reg a rts rstconf: pha; save reg a lda savc sta $ff00; restore configuration pla; restore reg a rts savc: 00 Here is a small demo that runs this code at $4000,$8000,$c000,$d000,$e000. drive.google.com/file/d/1VZKfu35m-CYzss-JYMS_Ov22A1S3HA82/view?usp=sharingYou can check the code with the in-built monitor after running the demo: monitor d 04000 04019; the code to print the text in the ram under Basic-rom low. d 08000 08019; the same code under Basic-rom high. d 0c000 0c019; the same code under the Screen Editor. d 0d000 0d019; the same code under I/O. d 0e000 0e019; the same code under the Kernal. d 01400 01420; the code to jump to $ffd2 in the kernal. For any other ROM subroutine change $ffd2. Memory selection on the c128 is located at $ff00 (it's a copy of $d500 and stays active even when I/O is switched off).
$ff00: bits 7,6 00=bank0 01=bank1 10=bank2 (if exists) 11=bank3 (if exists) bits 5,4 $c000-$ffff 00=kernal on 01=internal function rom (if exists) 10=external function rom (if exists) 11=ram bits 3,2 $8000-$bffff 00=basic rom high on 01 internal function rom (if exists) 10 external function rom (if exists) 11=ram bit 1 $4000-$7ffff 0=basic rom low on 1=ram bit 0 $d000-$dfff 0=system I/O 1=ram/rom depending on bits 5,4 (bits 5,4=1,1 then RAM, bits 5,4=0,0 then character ROM) Bank 0: All ROMs on: $ff00=$00. All ROMs and I/O off: $ff00=$3f. Basic high and low off, kernal on, I/O on: $ff00=$0e Addresses $ff00,$ff01,$ff02,$ff03 and $ff04 are always on. They can’t be switched off. They make it possible to change the memory configuration, regardless of the selected configuration.
|
|
|
Post by stiggity on Mar 11, 2021 4:11:04 GMT
Wendling: If I LDA#$0E, STA $FF00, JMP to subroutine within $8000-$BFFF how can i call these address's from within the $8000-$BFFF bank? jsr $8c75 jsr $8e44
I've got something going on, but preserving the MMU values, and flipping back in between...
and, if I bload"code",p45056,u(8) and tell MMU to bank correctly so I can access that code, if i RTS back to calling bank, does the code I loaded stay in memory?? sorry to sound like a grunt, but I'll figure this out. Im trying to setup a hi/low to FAC from within $8000-$BFFF. I almost have it, but the returned numbers aren't correct. I need to be able to call $8c75 and $8e44 while juggling buffers in the loaded, bank switched chunk of memory.
|
|
|
Post by stiggity on Mar 11, 2021 16:53:48 GMT
Wendling: N/M, i figured it out. It was late and night, and I was over-complicating things. Nothing like waking up, and looking at this pathetic code, After, a good nights rest. Thank you Very Much, for the breakdown of banks, and manipulating the MMU... This is just a starting point, as things are looking better. And the weather is finally cooperating! -Regards!!!
|
|
|
Post by stiggity on Mar 12, 2021 2:45:56 GMT
Wendling: I'm not smart enough to get this working on the c128, but I did manage to get it working on the c64. Would you/anybody be interested in looking at what I wrote, and somehow lend a hand in converting it to work on the 128??? I'm not going to post 50 lines of source, if nobody really wants too see it, plus I don't know how to post a .txt file.
|
|
|
Post by stiggity on Mar 12, 2021 19:56:08 GMT
;this is a c64 array handling method
astring = $B4F4 ; Allocates space on string heap; pass length in .A; address returned in .X/.Y and $35
FRETOP = $33
;fill buffer with data, into "buffer0"
;"buffer0 length is 'length'
;"index" is array element number
;"buffer" is element retrieved into itself
;"point" equals retrieved element length
jmp putary ;add buffer contents to array element#(index)
jmp getary ;retrieve an element#(index)
aray
LDA length
jsr ASTRING
rts
putary
JSR ARAY
LDA $2F
LDX $30
STA $FE
STX $FF
CLC
LDA $FE
ADC #7
STA $FE
BCC BRANC
CLC
LDA $FF
ADC #1
STA $FF
BRANC
inc index
LDX index
LDY #0
LOOP1x CLC
LDA $FE
ADC #3
STA $FE
BCC BR2
CLC
LDA $FF
ADC #1
STA $FF
BR2 DEX
BNE LOOP1x
heap LDY #0
ELOOP CPY length
BEQ DONE6
LDA BUFFER0,Y
notcr STA ($33),Y
INY
JMP ELOOP
DONE6 LDY #0
LDA length
STA ($FE),Y
INY
LDA fretop
STA ($FE),Y
INY
LDA fretop+1
STA ($FE),Y
rts
getary
LDA $2F
LDX $30
STA $FE
STX $FF
CLC
LDA $FE
ADC #7
STA $FE
BCC BRANCH
CLC
LDA $FF
ADC #1
STA $FF
BRANCH LDX index
LDY #0
LOOP1w CLC
LDA $FE
ADC #3
STA $FE
BCC BR2wa
CLC
LDA $FF
ADC #1
STA $FF
BR2wa DEX
BNE LOOP1w
LDY #2
LDA ($FE),y
STA $FD
dey
LDA ($FE),y
STa $FC ;holds element data
dey
LDA ($FE),y
sta point ;x (point) holds the length
ldy #0
qloop cpy point
bcs done1
lda ($FC),y
STA BUFFER,Y
inY
jmp qloop
done1 rts
as you notice, i didnt declare the array. This works for THE FIRST Array DIM'd..
|
|
|
Post by wendling on Mar 13, 2021 13:08:00 GMT
As you know: To read from bank1:
fetchfe lda #fe ldx #01 jmp ff74
fetchfc lda #fc ldx #01 jmp ff74
At getary: change: lda 2f , ldx 30 , sta fe , stx ff to: lda 31 , sta fe , lda 32 , sta ff
delete: ldx index , ldy #00
change every lda (fe),y to jsr fetchfe change lda (fc),y to jsr fetchfc
Now you can call getary from basic with the x-register as index. This fills the buffer with the value in the array at index = x. sys(getary),0,x
Could not a find a sys to free memory for a new string like your c64 routine: b4f4. But it was very easy to free memory: just subtract the needed bytes from stringtop address in 35/36.
putary lda 31; start of array memory sta fd lda 32 sta fe clc; skip the first 7 bytes of the array to get to the index lda fd adc #07 sta fd bcc L1 inc fe L1: clc; go to the index nr in reg x lda fd adc #03 sta fd bcc L2 inc fe L2: dex bne L1 ldy length lda fd ; the location in the array is stored after the string. sta buffer,y iny lda fe sta buffer,y iny sty len2 lda $35; Make room for string. Just 35/36 minus length string minus 2 for pointer. sec sbc len2 sta 35 lda 36 sbc #$00 sta 36 dey L3: lda buffer,y; store string in string memory jsr stash35 dey bpl L3 ldy #00 lda length; store length of new string in array memory jsr stashfd iny lda 35; store pointer low to new string in array memory jsr stashfd iny lda 36 ; store pointer high to new string in array memory jmp stashfd
length:05 len2:0 buffer:hallo; make this buffer large enough.
stash35; to store at 35/36 in string memory in bank1 pha lda #35 sta 02b9; modify the store address pla ldx #7f; bank1 jmp 02af
stashfd; to store at fd/fe in the array memory in bank1 pha lda #fd sta 02b9; modify the store address pla ldx #7f; bank1 jmp 02af
10 data monday,tuesday,wednesday 20 fort=0to2:reada$(t):next 30 fort=0to2:printa$(t):next:print 40 sys(putary),0,1 50 fort=0to2:printa$(t):next
run and result: monday tuesday wednesday
monday hello wednesday
About bank switching: When you switch to bank1 the program counter continues in bank1. Your program is not in bank1 so it crashes to the monitor which shows the program counter pointing to bogus data in bank1. To avoid this problem you have to setup een COMMON area. (Default: $0000-$03ff) This area is in bank0. When a bank addresses this area it doesn’t get access to the data in his own bank but instead gets access to the data in bank0. It’s here you can switch banks without problems.
The Common area is controlled by register $d506: bit 3,2 location of common area 0,0 no common area 0,1 bottom memory common (Default) 1,0 top of memory common 1,1 top and bottom memory common
bit 1,0 size of common area 0,0 1kb (Default) 0,1 4kb 1,0 8kb 1,1 16kb
bit 5,4 future ram expansion
bit7,6 VIC in bank: 0,0 bank0 0,1 bank1 1,0 bank2 1,1 bank3
|
|
|
Post by stiggity on Mar 13, 2021 23:55:40 GMT
Wendling: Yes! Thank You... fully understood and used as reference. Now, here's yet, Another question Lets say there a buffer, and its length. How can I store that into an address. Like is buffer="123", and LEN =3, and can I POKE? that buffer into a readable memory address??? Another explanation.. a buffer is parsed through, and _what's needed_ is stored into DEC 4020. I want to loop until my counter reaches memory address 4020. A.K.A, (Buffer0="123"). I'm hoping that makes sense, kind of like, the buffer will never be below 0 or above 255. how should i convert that buffer to single memory address...
|
|
|
Post by stiggity on Mar 14, 2021 0:10:06 GMT
Ok.. I'm only able to cross reference one of the below rom calls, the first one I couldn't locate, but here's what I came up with..
T2B1 lda #<P1BUF ldx #>P1BUF sta $22 stx $23 lda TLEN
jsr $b7b0 JSR $B7F7
lda $14 STA LINEBG RTS
what I'm attempting is a loop, or just a single entry, to POKE a string/buffer with length into a single memory address. GETADR=$B7F7, the $B7B0, I wasn't able to track down a label. So if BUFFER = "123" BUFLEN = 3
poke4020,(val(buffer)) in ASM..
-Thank You sooo much, Wendling...once I saw you replied, and while reading your response, I was like "Yes!!!! :-)
|
|