128k paging BASIC loader

The place for codemasters or beginners to talk about programming any language for the Spectrum.
User avatar
R-Tape
Site Admin
Posts: 1431
Joined: Thu Nov 09, 2017 11:46 am

128k paging BASIC loader

Post by R-Tape » Fri Dec 08, 2017 12:47 pm

This is the scenario:

Stack below 24064, main code fills 24064 up to the top, including vector table at 65024 in main (=bank 0?) filled with db 253, JPs to interrupt routine at 32768.

Interrupt routine will page in bank 1, call AY music there, then page bank 0 back in.

I'm struggling to get the code loaded into bank 1, and make it all work.

This is the loader.

10 CLEAR 24063:LOAD"MAIN"CODE ;regular code into main memory with bank 0 at the top
20 IF PEEK 23388 THEN OUT 32765,17:LOAD"AYMUSIC"CODE:OUT 32765,16 ;AY music loaded into bank 1
30 RANDOMIZE USR 24064

I'm getting crashes, it's possible it's because of the return to BASIC within the editor. Should the above strategy work?

I hate coding for the 128k.
0 x

User avatar
bob_fossil
Dizzy
Posts: 99
Joined: Mon Nov 13, 2017 6:09 pm

Re: 128k paging BASIC loader

Post by bob_fossil » Fri Dec 08, 2017 12:56 pm

Had a look at some old 128 .tap conversions I did from years ago and I was doing the following to page from BASIC:

Code: Select all

POKE VAL "23388", a: OUT VAL "32765",a
with a being the page, e,g. 16.

This seemed to work without problems.

Bob Fossil
1 x

User avatar
Seven.FFF
Manic Miner
Posts: 259
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: 128k paging BASIC loader

Post by Seven.FFF » Fri Dec 08, 2017 1:07 pm

I would compress the part that’s overwriting basic, and load that at a higher address or in another bank. Have the entry point be high, and make it decompress the low chunk before starting.

I hate loaders that return to basic. I’m trying to figure out the same process for Pentagon loaders, which involves making TR-DOS m/c calls from the loader too. Ugh.

Zeus has a really nice integrated 128K scatterloader. It uses the Halls of The Things loader that displays the loading screen in line order. Even if you don’t want to use Zeus for main dev, you could call the command line version of Zeus as part of your build process. It would just need to import all your binary chunks (which it can do all at once because it maps each page to a virtual 32-bit address) and export the tap and tax.
0 x
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
seven-fff.com/blog

User avatar
Seven.FFF
Manic Miner
Posts: 259
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: 128k paging BASIC loader

Post by Seven.FFF » Fri Dec 08, 2017 1:12 pm

This is how simple a zeus paging loader is:

Code: Select all

  TapeMode equ 3
  BorderOptions equ $00002353
  output_tzx "..\bin\Tumult-Uncompressed.tzx", "Tumult", "(c) Robin Verhagen-Guest 2017", Page52Start32, Page52Size, TapeMode , EntryPoint, BorderOptions 
  output_tzx_block "..\bin\Tumult-Uncompressed.tzx", Page0Start32, Page0Size
  output_tzx_block "..\bin\Tumult-Uncompressed.tzx", Page1Start32, Page1Size
  output_tzx_block "..\bin\Tumult-Uncompressed.tzx", Page3Start32, Page3Size
  output_tzx_block "..\bin\Tumult-Uncompressed.tzx", Page4Start32, Page4Size
  output_tzx_block "..\bin\Tumult-Uncompressed.tzx", Page6Start32, Page6Size
  output_tzx_block "..\bin\Tumult-Uncompressed.tzx", Page7Start32, Page7Size
Exactly the same for taps except the command is output_tap.

In that example Page52Start32 = $6000 and Page52Size = $6000 (i.e. from $6000-$BFFF). This overwrites basic, but it doesn't matter because the loader never returns to basic.
0 x
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
seven-fff.com/blog

User avatar
Ast A. Moore
Manic Miner
Posts: 603
Joined: Mon Nov 13, 2017 3:16 pm

Re: 128k paging BASIC loader

Post by Ast A. Moore » Fri Dec 08, 2017 1:21 pm

For starters, returning to BASIC will change the top bank to bank 7. It will also automatically select ROM 0 for you, so no need to set bit 4. Most importantly, you need to disable interrupts and keep the system variable at 23388 updated with the value you send to the port.

I recommend you write a small MC loader and stick it into BASIC. Then run the whole thing with RANDOMIZE USR (PEEK 23635+256*PEEK 23636+5).
0 x
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.

Woodster
Berk
Posts: 11
Joined: Mon Nov 13, 2017 12:17 pm

Re: 128k paging BASIC loader

Post by Woodster » Fri Dec 08, 2017 2:50 pm

R-Tape wrote:
Fri Dec 08, 2017 12:47 pm
10 CLEAR 24063:LOAD"MAIN"CODE ;regular code into main memory with bank 0 at the top
20 IF PEEK 23388 THEN OUT 32765,17:LOAD"AYMUSIC"CODE:OUT 32765,16 ;AY music loaded into bank 1
30 RANDOMIZE USR 24064
Try:
20 POKE 23388,17: PAUSE 1: LOAD"AYMUSIC" CODE: POKE 23388,16: PAUSE 1 ;AY music loaded into bank 1
1 x

User avatar
Seven.FFF
Manic Miner
Posts: 259
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: 128k paging BASIC loader

Post by Seven.FFF » Fri Dec 08, 2017 3:18 pm

Ast A. Moore wrote:
Fri Dec 08, 2017 1:21 pm
For starters, returning to BASIC will change the top bank to bank 7.
Woodster wrote:
Fri Dec 08, 2017 2:50 pm
20 POKE 23388,17: PAUSE 1: LOAD"AYMUSIC" CODE: POKE 23388,16: PAUSE 1 ;AY music loaded into bank 1
Does Woody's technique stop BASIC changing the top bank back to bank 7, then?
0 x
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
seven-fff.com/blog

User avatar
Spud
Microbot
Posts: 142
Joined: Sun Nov 12, 2017 8:50 pm

Re: 128k paging BASIC loader

Post by Spud » Fri Dec 08, 2017 3:49 pm

Can you compress as much as possible, load it in to whatever standard banks are paged in by default and then splurge it all over the other banks once you're in your program? That's what I did. I recognise if all your data you're loading in won't fit at once then it won't work.
0 x

Hikaru
Microbot
Posts: 100
Joined: Mon Nov 13, 2017 1:42 pm
Location: Russia
Contact:

Re: 128k paging BASIC loader

Post by Hikaru » Fri Dec 08, 2017 5:47 pm

USR0 it with fire!
1 x
Inactive account

User avatar
Ast A. Moore
Manic Miner
Posts: 603
Joined: Mon Nov 13, 2017 3:16 pm

Re: 128k paging BASIC loader

Post by Ast A. Moore » Fri Dec 08, 2017 6:37 pm

Seven.FFF wrote:
Fri Dec 08, 2017 3:18 pm
Does Woody's technique stop BASIC changing the top bank back to bank 7, then?
Well, kind of. Until the machine resets. ;)
However, if you OUT 32765,17: POKE 23388,17, it’ll page in bank 1 and reset into 48K BASIC, and the bank will stick.
0 x
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.

Post Reply