Image Map Image Map
Results 1 to 4 of 4

Thread: Bank switching on the c128 for peeks and pokes

  1. Default Bank switching on the c128 for peeks and pokes

    Hello,

    I'm having some trouble understanding the use of Bank in C128 basic.
    I'm currently working through theAdvent of Code challenges doing a different language for each day.
    For day 6 I've decided to use basic on the C128, however I need to store a map about 128k in size.
    Therefore I was hoping that bank switching on an extended c128 would help me out.
    However, I must be missing something because I can't seem to get it to work. As an example the following program corrupts memory being used for basic.
    Whereas I thought it would be writing into a separate 64k bank 1.

    Code:
    10 mx = 14: my = 14
    20 bank 1
    20 for x = 0 to mx
    50 for y = 0 to my
    60 poke (x*y), 255
    70 if peek(x*y) <> 255 then print "wrong val at: ";x;",";y
    80 next y
    90 next x
    100 bank 15
    Any help with this would be most appeciated.

    Best wishes

    Lorry
    TechTinkering
    Retro computers, Programming and General Technical Tinkering
    Latest Article: Advent of Code 2018: 25 Days, 25 Languages

  2. Default

    I haven't been able to work out how to store data in bank 1 (the second 64k) of the internal memory.
    However, I have been able to work out how to store data in an REU which is great for my purpose.
    In case anyone's interested here's how I did it.

    Code:
    10 mx = 357: my = 357
    20 n = 0
    30 i = 0
    40 b = 0
    50 l = dec("0e00"):rem rs-232 buffer
    60 for x = 0 to mx
    70 print "store x: ";x
    80 for y = 0 to my
    90 if n < 254 then n = n +1: else n = 0
    100 poke l+y, n
    110 next y
    120 stash my+1, l,i ,b
    130 i=i+my+1
    140 if i >= 65535 then i=0:b=b+1
    150 next x
    160 n = 0
    170 i = 0
    180 b = 0
    190 for x = 0 to mx
    200 print "fetch x: ";x
    210 fetch my+1, l, i, b
    220 i=i+my+1
    230 if i >= 65535 then i=0:b=b+1
    240 for y = 0 to my
    250 if n < 254 then n = n +1: else n = 0
    260 if peek(l+y) <> n then print "wrong val at: ";x;",";y
    270 next y
    280 next x
    I would still be interested though, if someone could explain what I'm
    misunderstanding about the use of the second internal bank in my first post.
    TechTinkering
    Retro computers, Programming and General Technical Tinkering
    Latest Article: Advent of Code 2018: 25 Days, 25 Languages

  3. Default

    Quote Originally Posted by Lawrence Woodman View Post
    I haven't been able to work out how to store data in bank 1 (the second 64k) of the internal memory.
    However, I have been able to work out how to store data in an REU which is great for my purpose.
    In case anyone's interested here's how I did it.
    ...
    I would still be interested though, if someone could explain what I'm
    misunderstanding about the use of the second internal bank in my first post.
    Sorry, to have a conversation with myself on this thread, but I've just found a reference
    on another website to the banks just being memory configurations not true access to
    blocks of memory. It turns out that basic uses block 1 for variables.hence the reason
    for the corruption. It's a shame that the system guide doesn't make it more clear,
    maybe in the next revision

    On a positive note, hopefully I'll have my solution for day 6 written up and tested
    using c128 basic tomorrow and I expect it'll be the only solution using this truly
    great vintage computer (at least in my eyes).
    TechTinkering
    Retro computers, Programming and General Technical Tinkering
    Latest Article: Advent of Code 2018: 25 Days, 25 Languages

  4. #4

    Default

    I was just about to type that very thing. The 8502 is still just accessing 64K; the MMU only changes the mapping of individual blocks within that 64K. The BANK command is even more limited from the perspective that it only affects PEEK, POKE, WAIT and SYS, and only offers one of 16 pre-defined configurations (see pages 28 and 460-62 in the 128 PRG).

    Realistically, to store that much in RAM, you're going to have to use assembly. The BASIC program text occupies BANK 0 and, as you found out, variables are in BANK 1, so you're going to stomp all over yourself at some point if you try to use BASIC.
    I use my C128 because I am an ornery, stubborn, retro grouch. -- Bob Masse
    Machine room: http://www.floodgap.com/etc/machines.html

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •