Jump to content
IGNORED

An Anti-Basic Rom/Cartridge


Recommended Posts

Something had me wondering last night.  Never have luck disabling basic in the XL/XE environment 100% of the time.  I know it sounds silly, but always found having to disable basic to be an unnecessary step.

 

Would it be possible to make a stand in rom for basic?   So the computer will look where basic is, but automatically just say "nothing to see here, move along..."   Perhaps something to just simply activate option without having the hold down option?

 

Link to comment
Share on other sites

If you plug in any cartridge, it's going to swap out the RAM from $A000-$BFFF (or $8000-$9FFF with 800 right cartridge) so it's defeating the purpose. BASIC would be disabled, but you would still not have RAM there.

 

I assume you're not using SpartaDOS. You could probably write a quick AUTORUN.SYS program to toggle the "BASIC enabled" byte in PORTB.

 

Link to comment
Share on other sites

I did that once with a 1090XL firmware board.  It could easily be done with a cartridge.  The cartridge should have it's own latch, via a $D5xx address, to disable itself.  It would also have to copy a little bit of code to RAM.  So, it would be like this:

 

1.  OS runs cartridge

2.  Cartridge code disables BASIC via PORTB.

3.  Cartridge code copies a small section of code to main memory.  (This section turns off the cartridge bank, sets the new top of RAM, and exits back to the OS..)

4.  Cartridge code runs the section it just copied to main memory.

Link to comment
Share on other sites

Some carts can bank the Rom out.

Possibly the INIT section could do that and return but much of it would need to run from Ram, although the sequence could be as little as STA $D5xx / RTS.  That code could be pushed to the stack, then stack adjusted and jumped to.

For the trouble you'd be better off just doing a custom OS that defaults to Basic off.

Edited by Rybags
Link to comment
Share on other sites

This highlights how spoiled I have been for decades now.  Starting with Tucker's 32-in-1 OS upgrade, then moving onto U1MB.  I don't even have a machine any more that has the stock OS.  I get so many benefits from custom OS.  Reverse BASIC, hi-speed SIO, etc.

  • Like 1
Link to comment
Share on other sites

1 hour ago, Stephen said:

This highlights how spoiled I have been for decades now.  Starting with Tucker's 32-in-1 OS upgrade, then moving onto U1MB.  I don't even have a machine any more that has the stock OS.  I get so many benefits from custom OS.  Reverse BASIC, hi-speed SIO, etc.

 

The U1MB should in a lot of ways be what the Incogneto is.  But of the XE and XE OS they have listed, they all have basic as a default.

(I try to load like the IRC chat under XL/XE 320k and it either comes up in basic, memory test, etc.)

 

Thanks for the answers to my questions all!

 

Link to comment
Share on other sites

  • 1 month later...
On 10/31/2023 at 2:28 PM, reifsnyderb said:

I did that once with a 1090XL firmware board.  It could easily be done with a cartridge.  The cartridge should have it's own latch, via a $D5xx address, to disable itself.  It would also have to copy a little bit of code to RAM.  So, it would be like this:

 

1.  OS runs cartridge

2.  Cartridge code disables BASIC via PORTB.

3.  Cartridge code copies a small section of code to main memory.  (This section turns off the cartridge bank, sets the new top of RAM, and exits back to the OS..)

4.  Cartridge code runs the section it just copied to main memory.

No need for code in RAM.  Just have the init address for the cartridge be in the register space, and have the cartridge set so reads from the register space come from the ROM.  So reads from D5xx would be from the ROM, and the cartridge initialization address would be D500.  The code there would, as described, disable BASIC in PORTB and then disable the cartridge itself, but leaving the D5xx window open.  The key here is that the D5xx window doesn't have to be just hardware registers, especially if they're write-only.

 

Related: I was thinking you could have a cartridge that did everything in the D5xx window and immediately re-enabled the RAM under it on initialization.  In theory it could use writes to page swap the ROM into that window.  With some extremely clever hacking, you might be able to get something like DOS to run that way, taking up no code space.  And this would work the same as a left or right cartridge on an 800.

  • Like 1
Link to comment
Share on other sites

The problem with a cart present is that the memory map (screen, top of Ram pointer etc) will reflect that even after the cart disables itself.

So you'd get a boot situation where it's possible that the game or whatever thinks you only have 40K.

In theory you could disable cart, re-open screen etc but it starts to get complicated and you can have unwanted residual data left in parts of Ram.

Link to comment
Share on other sites

6 hours ago, Rybags said:

The problem with a cart present is that the memory map (screen, top of Ram pointer etc) will reflect that even after the cart disables itself.

So you'd get a boot situation where it's possible that the game or whatever thinks you only have 40K.

In theory you could disable cart, re-open screen etc but it starts to get complicated and you can have unwanted residual data left in parts of Ram.

True, you would have to manually verify that the memory exists (not 600XL or 400/800 with less than 48K).  Then update RAMTOP and issue GR.0.  Wiping the old display list below 40K would be a bonus.  If RAMTOP were below A0, then you know it's not RAM under the cartridge, so the only issue would be an 800 with two 16K RAM boards and one 8K board (exactly 40K).  I bet it could all be done in 32 bytes of code.  Easy in 256 bytes in D5xx.

Link to comment
Share on other sites

11 hours ago, Rybags said:

The problem with a cart present is that the memory map (screen, top of Ram pointer etc) will reflect that even after the cart disables itself.

So you'd get a boot situation where it's possible that the game or whatever thinks you only have 40K.

In theory you could disable cart, re-open screen etc but it starts to get complicated and you can have unwanted residual data left in parts of Ram.

The following code works for putting BASIC in the right cartridge slot on an 800.  The right cartridge is a banked cartridge and can turn off all banks.  I've made up the cartridge and keep it in the right slot of my 800.

 

However, if reading from CCTL would read the ROM code that turns off the cartridge, any cartridge disabling code would not have to be copied to RAM like I did.

 

Here's the code:

 

 

 

.INCLUDE "camac.inc"


; Right cartridge BASIC loader
; Written by Brian E. Reifsnyder

 

; Address Equates
TSTDAT    EQU        $0007
DOSVEC     EQU        $000A
RAMTOP    EQU        $006A
TSADR        EQU        $00CC
TDADR        EQU        $00CE
RAMSIZ    EQU        $02E4
LCARTF    EQU        $4FE0
CONSOL    EQU        $D01F
RCCTL        EQU        $D5A0

 


; LCARTF Equates
LCNONE    EQU        $00            ; No cartridge at all.
LCRC        EQU        $7F            ; Right cartridge copied to left RAM.
LCALC        EQU        $FF            ; Actual left cartridge.

 

 

;**    FIX - Fix Address
;*
;*    FIX sets the origin counter to the value specified as an
;*    argument.  If the current origin counter is less than the
;*    argument, FIX fills the intervening bytes with zero and
;*    issues a message to document the location and number of
;*    bytes that are zero filled.
;*
;*    "Borrowed" from Atari OS source code.


.macro    FIX    address
    .if    * > address
    .error    .sprintf("$%04x precedes current origin counter of $%04x", address, *)
    .elseif * < address
    .out    .sprintf("$%04x free bytes from $%04x to $%04x", address-*, *, address-1)
    .res    address-*, $00
    .endif
.endmacro

 

 

 

ORG    $8000

; Copy main program to $4000 then jump to main program.

            LDA        #$00                ; Setup source and destination addresses
            STA        TSADR
            STA        TDADR
            
            LDA        #$90
            STA        TSADR+1
            
            LDA        #$40
            STA        TDADR+1

            LDX        #$03                ; Copy only 256 bytes * 4 (or 1024) bytes.  This should be plenty.
            
CPYOL1                                ; Outer loop running 4 times.
            LDY        #$FF

CPYIL                                    ; Inner loop copying 256 bytes at a time.
            LDA        (TSADR),Y
            STA        (TDADR),Y
            CPY        #$00
            BEQ        CPYOL2
            DEY
            JMP        CPYIL

CPYOL2            
            INC        TSADR+1
            INC        TDADR+1
            DEX
            BPL        CPYOL1


; Jump to main program
            JMP        MAIN

; Main program, starting at $4000
FIX $9000
LOC    $4000

MAIN

            LDA        #LCNONE    ; Assume no cartridge in left slot.
            STA        LCARTF

; Check for physical cartridge in left slot
; If there is a physical cartridge, disable the right cartridge, reset RAM, and exit.
            LDX        $BFFF        ; Store byte
            
            LDA        #$22
            STA        $BFFF        ; Save test byte
            
            LDA        $BFFF
            CMP        #$22            ; Has test byte been saved?
            BNE        LCROM    ; It hasn't.  ROM is in this location.
            
            STX        $BFFF        ; Test byte was saved.  Put original back.  We have RAM here.

; Check for Select key down

            LDA        CONSOL
            AND        #$02                ; Is SELECT key pressed?
            BNE        NOLOAD        ; SELECT key is not pressed.

            JMP        INSBAS        ; Install BASIC from right cartridge.

 

LCROM
            LDA        #LCALC        ; An actual ROM is in the left cartridge slot.
            STA        LCARTF        ; Store this.
NOLOAD
            JMP     DONE

        


; Change cartridge bank to Altirra BASIC bank
; (Altirra BASIC bank is bank 2, set as #%00000001)
INSBAS
            LDA        #%00000001
            STA        RCCTL

; Copy BASIC from $8000-$9FFF to $A000-$BFFF


            LDA        #$00                ; Setup source and destination addresses
            STA        TSADR
            STA        TDADR
            
            LDA        #$80                ; Source page
            STA        TSADR+1
            
            LDA        #$A0            ; Dest page
            STA        TDADR+1

            LDX        #$1F                ; Copy $20 pages.
            
BCPOL1                                ; Outer loop running $20 times.
            LDY        #$FF

BCPIL                                    ; Inner loop copying 256 bytes at a time.
            LDA        (TSADR),Y
            STA        (TDADR),Y
            CPY        #$00
            BEQ        BCPOL2
            DEY
            JMP        BCPIL

BCPOL2            
            INC        TSADR+1
            INC        TDADR+1
            DEX
            BPL        BCPOL1

            LDA        #LCRC            ; Consider the loaded BASIC to be a cartridge and
            STA        LCARTF        ; set it as so.

DONE
; Set OS right cartridge flag to indicate cartridge doesn't exist.
            LDA         #$00
            STA        TSTDAT

; Reset banks and turn off right cartridge
            LDA        #%00001100
            STA        RCCTL

 


; Set top of RAM (RAMTOP)
; Note that for this to work, the Atari must have 48k of base memory.
            LDA        LCARTF
            
            BEQ        DNOCT                ; = LCNONE
            BPL        DRCT                ; = LCRC
            BMI        DALC                ; = LCALC
            
DNOCT                                        ; No left cartridge installed
            LDA        #$C0
            BNE        DSRT

DRCT                                        ; Right cartridge copied to left RAM
            LDA        #$A0
            BNE        DSRT

DALC                                        ; Actual physical cartridge found
            LDA        #$A0
                        
DSRT
            STA        RAMTOP
            STA        RAMSIZ

; Return
            RTS


FIX    $4FFA
ORG    $9FFA
DW    $0000        ; CARTCS
DB    $00            ; CART
DB    $00            ; CARTFG
DW    $8000        ; CARTAD

 

  • Like 1
  • Thanks 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...