Jump to content
IGNORED

Memory Banking in Hybrid Basic & Assembler


Recommended Posts

looking at the source in my post 8, there are only these 4 locations where an absolute address is used:

0667: 20 2C 06 JSR $062C

0671: 20 00 06 JSR $0600

0694: 20 00 06 JSR $0600

06CF: 20 2C 06 JSR $062C

 

If you place the code at the begin of $xy00, then you only need to replace the $06 (3rd byte) by $xy there.

I'd poke/load the routine to "start" (plain page) and the

 

start=$xy000

poke start+$69,start/256

poke start+$73,start/256

poke start+$96,start/256

poke start+$d1,start/256

 

Edited by JAC!
Link to comment
Share on other sites

OK, another beginner question:

 

It seems the best way for this to work is to place the code on a page boundary. Assuming this is true, are there any other good places to store this code (244 bytes) besides Pages 4 and 6? One thing I had thought of doing was placing this at the end of my PMBASE below RAMTOP. I've figured out that I would need to reserve PEEK(106)-24 to cover 4K worth of font data plus PMG's in double line resolution. Would this be enough to also store my code, or do I need to reserve more pages? Or alternatively, another spare 244 bytes elsewhere in RAM to store this thing?

Link to comment
Share on other sites

  • 8 years later...

Does anyone can help me with some strange behaviour in my program.

When 4-th bit of PORTB flips/flops GR0 screen blinks and output crashes.

After turning ON/OFF all goes normally

Your any suggestions will be very appreciated.

 

It's PL65 sample code.

!====================================!
! BANKS.PRG                          !
!   Using 130XE Extended Banks in    !
!     PL65 Programming Language      !
!------------------------------------!
! Evgeny Zolotarev,(aka 576XE), 2020 !
!====================================!
INCLUDE TERMINAL.LIB

!- CONSTANTS & VARIABLES:
CONST bkMask=%10010001
BYTE PORTB=$D301,NMIEN=$D40E,bkTag
INT bkNum

!- DUMMY array representing ---------!
!- selected BANK_s slice ------------!
BYTE bkMem[$4000]=$4000

!- Bank Selector Values -------------!
!- Atari800WinPlus 576XE ------------!
BYTE bkSel[33]
  DATA $91,
    $81,$83,$85,$87,$89,$8B,$8D,$8F,
    $A1,$A3,$A5,$A7,$A9,$AB,$AD,$AF,
    $C1,$C3,$C5,$C7,$C9,$CB,$CD,$CF,
    $E1,$E3,$E5,$E7,$E9,$EB,$ED,$EF;

! String VAR  to store in all BANKS
STRING inp$[4+27]
  DATA "==> User DATA from Bank #00";

! Set string as VAR for appending
STRING out$[4+27]
  DATA "                           ";

!- PROCEDURES:
!- Clear Screen Procedure -----------!
PROC clrScr()
  CONST clr=255
BEGIN WRTSTR(CHR$(125)) END

!- Wait for Any Key Pressed ---------!
PROC anyKey()
  CONST none=255
  BYTE CH=764
BEGIN
  WRTSTR("Wait for a Key...") CR()
  WHILE CH=none DO ENDWHILE
  CH=none
END

PROC setBk*(BYTE bkTag)
BEGIN
! Wrapper STOPs/STARTs IRQ & NMI
  SEI LDA #$00 STA NMIEN

  LDA PORTB
  AND bkMask OR bkTag
  STA PORTB

  LDA #$40 STA NMIEN CLI
END

!- Place bkSel Tags into PORTB ------!
PROC setBank(INT bkNum)
BEGIN
  bkTag=bkSel[bkNum]
  setBk*(bkTag)
END

!- Writes to Bank -------------------!
PROC writBk()
BEGIN
  FOR bkNum=0 TO 32 DO
    WRTSTR("Writing to BANK #") WRITE(bkNum) CR()
    IF bkNum<10 THEN
      inp$[25,25]=STR$(0) inp$[26,26]=STR$(bkNum)
    ELSE inp$[25]=STR$(bkNum) ENDIF
    out$=inp$
    setBank(bkNum)
    MOVE(.out,LEN(out$),.bkMem)
  NEXT
END

!- Reads from Bank ------------------!
PROC readBk()
BEGIN
  FOR bkNum=0 TO 32 DO
    WRTSTR("Reading BANK #") WRITE(bkNum) CR()
    setBank(bkNum)
    MOVE(.bkMem,LEN(out$),.out)
    WRTSTR(out$) CR()
  NEXT
END

!------------------------------------!
MAIN()
BEGIN
  clrScr() anyKey() writBk()
  anyKey() clrScr() readBk()
END
! >>> EOF <<< !

zen

Edited by 576XE
Link to comment
Share on other sites

  • 2 weeks later...

PORTB Bit 4 turns the CPU access to extended 130XE memory at $4000-$7FFF on and off.

If the screen lives in that area then you could easily corrupt any data you have in extended Ram.

If a Basic program is in there, which is very likely if a Dos is loaded then you potentially switch part of it out and crash - and not forgetting stuff like strings and the stack for loops/subs lives above the program.

Also remember, default bitsettings for everything except Basic are 1.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...