Ähmm can I use this trick vice versa to let big programs run on my 1k Zeddy at home ?
Set RAMTOP up and type CLEAR ?
Lowering RAMTOP without a reset
Re: Lowering RAMTOP without a reset
I made a program for ZX81 with 16K RAM (or higher) that makes RAMTOP as large as possible but still with small D_FILE (i.e. 3.25K). I load this before I enter a program. This makes it faster to enter programs and makes the filesize smaller and more probable to load on a 1K ZX81.
Code: Select all
2 SAVE "SMALLDFILE"
3 LET D=16389
5 GOSUB 1000
10 POKE D,76
15 POKE D-1,255
20 GOSUB 1000
30 PRINT "PRESS: A(=NEW) AND NEWLINE"
999 STOP
1000 PRINT PEEK D*256+PEEK (D-1)-16384
1010 RETURN
Started w/ BASIC on ABC80 & ZX81 then Forth, Z80… http://scratch.mit.edu/users/mobluse/ https://www.youtube.com/user/MOBiL4u/ https://twitter.com/mobluse/
- 1024MAK
- Posts: 5302
- Joined: Mon Sep 26, 2011 10:56 am
- Location: Looking forward to summer in Somerset, UK...
Re: Lowering RAMTOP without a reset
Yes, as long as you use M!cro$oft's virtual memory system for your ZX81. Guaranteed to make it run faster*. Don't forget to set up your page file.PokeMon wrote:Ähmm can I use this trick vice versa to let big programs run on my 1k Zeddy at home ?
Set RAMTOP up and type CLEAR ?
* when the video picture is recorded and played back at x1000 speed.
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer being good this year.
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer being good this year.
Re: Lowering RAMTOP without a reset
Great routine.Andy Rea wrote: ↑Wed Jan 11, 2012 6:16 pm i just wrote a routine that copies the entire current stack to the new stack location, it is safe to call it from basic using a RAND USR xxx and as long as your new stack location is above STKEND (the calculator stack) it should work just fine.
might not be the quickest, but since as my program needs to return to basic along with the value in BC i needed to ensure that the other items on the stack got executed too.Code: Select all
STACK_MOVE: OUT ($FD),A ;TURN OFF NMI'D ;INTS SHOULD ALREADY BE DISABLED LD HL,-4 ADD HL,SP ;GET THE SP LD D,H LD E,L ;PUT IN DE LD HL,($4002) ;GET err-sp OR A ;CLEAR CARRY FLAG SBC HL,DE ;SHOULD HAVE NUMBER OF BYTES IN CURRENT STACK LD B,H LD C,L ;INTO BC LD DE,28282 LD (16388),DE ;NEW RAMTOP DEC DE ;DE PTR READY TO RECIEVE COPY OF STACK LD HL,$7FFF LDDR ;COPY STACK TO NEW LOCATION LD HL,28278 LD ($4002),HL ;NEW err_sp LD H,D LD L,E INC HL LD SP,HL OUT ($FE),A
Andy
This lowers the RAMTOP. If I want to raise the RAMTOP again, could I just replace LDDR with LDIR?
Re: Lowering RAMTOP without a reset
Well - this routine is not to recommend as it works only if there is no overlap between source and target buffer. To move a memory block from higher to lower address you should use LDIR instead of LDDR as LDDR may overwrite some copied data if both buffers overlap. For moving a memory block up, LDDR is typically used. Both methods are robust against possible buffer overlap. Of course, the pointers DE and HL have to be adjusted properly.mrtinb wrote: ↑Wed Mar 08, 2017 1:45 pmGreat routine.Andy Rea wrote: ↑Wed Jan 11, 2012 6:16 pm i just wrote a routine that copies the entire current stack to the new stack location, it is safe to call it from basic using a RAND USR xxx and as long as your new stack location is above STKEND (the calculator stack) it should work just fine.
might not be the quickest, but since as my program needs to return to basic along with the value in BC i needed to ensure that the other items on the stack got executed too.Code: Select all
STACK_MOVE: OUT ($FD),A ;TURN OFF NMI'D ;INTS SHOULD ALREADY BE DISABLED LD HL,-4 ADD HL,SP ;GET THE SP LD D,H LD E,L ;PUT IN DE LD HL,($4002) ;GET err-sp OR A ;CLEAR CARRY FLAG SBC HL,DE ;SHOULD HAVE NUMBER OF BYTES IN CURRENT STACK LD B,H LD C,L ;INTO BC LD DE,28282 LD (16388),DE ;NEW RAMTOP DEC DE ;DE PTR READY TO RECIEVE COPY OF STACK LD HL,$7FFF LDDR ;COPY STACK TO NEW LOCATION LD HL,28278 LD ($4002),HL ;NEW err_sp LD H,D LD L,E INC HL LD SP,HL OUT ($FE),A
Andy
This lowers the RAMTOP. If I want to raise the RAMTOP again, could I just replace LDDR with LDIR?
Best code would be (for a buffer without adjusting stack pointer):
You can read something more detailed here; moving down
LD DE,end_buffernew
LD HL,end_bufferold
LD BC,buffersize
LDDR
;moving up
LD DE,start_buffernew
LD HL,start_bufferold
LD BC,buffersize
LDIR
http://sgate.emt.bme.hu/patai/publicati ... part3.html
(moving data blocks)
Re: Lowering RAMTOP without a reset
In a p-file there are some unused bytes that could hold a routine to lower RAMTOP for those programs that need that. Old p files could be upgraded to contain this routine and then you would call it from the BASIC program. Sea Mines needs lower RAMTOP and it might be possible to fix it so that you don't need to POKE and NEW before LOADing it, but instead you just LOAD and RUN it.
POKE 16389,103
NEW
(That would correspond to 9.75 KiB RAM, but then it uses the RAM above that up to 16 KiB.)
The p-file for the game Sea Mines is here:
https://www.sinclairzxworld.com/viewtop ... 463#p51463
The article with the game and the errata is here:
https://www.sinclairzxworld.com/viewtopic.php?f=7&t=325
Someone else also entered SeaMines, but that is a hacked version:
https://www.sinclairzxworld.com/viewtop ... 079#p48079
Note that Sea Mines only works with some official ZX81 ROMs and not with e.g. x2 (Big Bang).
POKE 16389,103
NEW
(That would correspond to 9.75 KiB RAM, but then it uses the RAM above that up to 16 KiB.)
The p-file for the game Sea Mines is here:
https://www.sinclairzxworld.com/viewtop ... 463#p51463
The article with the game and the errata is here:
https://www.sinclairzxworld.com/viewtopic.php?f=7&t=325
Someone else also entered SeaMines, but that is a hacked version:
https://www.sinclairzxworld.com/viewtop ... 079#p48079
Note that Sea Mines only works with some official ZX81 ROMs and not with e.g. x2 (Big Bang).
Started w/ BASIC on ABC80 & ZX81 then Forth, Z80… http://scratch.mit.edu/users/mobluse/ https://www.youtube.com/user/MOBiL4u/ https://twitter.com/mobluse/