Jump to content
IGNORED

Disabling basic with cc65


Recommended Posts

Hi,

 

I cant figure out how to disable BASIC properly via PORTB(by enabling second bit) when using CC65.

If done in main(), it does not have desired effect. As I've read so far, it seems that is needed to do it sooner before reaching main().

There is probably something trivial I'm missing. Thanks.

 

 

Link to comment
Share on other sites

You could try injecting a section before EXEHDR in SEGMENTS:

 

BASICOFF: load = BASICOFF, type = ro;

 

define this in MEMORY after HEADER as:

 

BASICOFF: file = O%, start=$0000, size = $0005;

 

and then in a code file implement this as:

 

.segment "BASICOFF"

.word PORTB

.word PORTB

.byte $FF

 

you could alternatively make a code block to LDA #$FF / STA PORTB / RTS with their own HDR and INIT section wrappers but that's a bit more effort. 

  • Like 1
Link to comment
Share on other sites

On 5/2/2023 at 1:42 AM, Wrathchild said:

You could try injecting a section before EXEHDR in SEGMENTS:

 

BASICOFF: load = BASICOFF, type = ro;

 

define this in MEMORY after HEADER as:

 

BASICOFF: file = O%, start=$0000, size = $0005;

 

and then in a code file implement this as:

 

.segment "BASICOFF"

.word PORTB

.word PORTB

.byte $FF

 

you could alternatively make a code block to LDA #$FF / STA PORTB / RTS with their own HDR and INIT section wrappers but that's a bit more effort. 

Thanks, seems to do the job. I had to adjust few things and my existing display lists seem to have become little "unreliable" but that needs more investigation.

Link to comment
Share on other sites

Additional to all this - if you want rid of Basic when the user presses Reset you need to set $3F8 nonzero.

Also there's the default screen problem - the text screen will occupy top of contiguous Ram which on a 48K or bigger system will either be around $9C00 or $BC00, which can have potential to corrupt a loaded program if it occupies the same area then screen output occurs later.

 

Link to comment
Share on other sites

The code from @JAC! is also worth mentioning:

(https://www.wudsn.com/index.php/productions-atari800/tutorials/tips)

 

       ORG $2000

LOADER LDA #$c0 ;Check if RAMTOP is already OK
       CMP $6a ;This prevent flickering if BASIC is already off
       BEQ RAMOK
       STA $6a ;Set RAMTOP to end of BASIC
       STA $2E4 ;Set RAMSIZ also

       LDA $d301 ;Disable BASIC bit in PORTB for MMU
       ORA #$02
       STA $d301

       LDA $a000 ;Check if BASIC ROM area is now writeable
       INC $a000
       CMP $a000
       BEQ RAMNOK ;If not, perform error handling....

       LDA #$01 ;Set BASICF for OS, so BASIC remains OFF after RESET
       STA $3f8

       LDX #2 ;Close "E:" before re-openining it again
       JSR EDITOR
       LDX #0 ;Open "E:" to ensure screen is not at $9C00
EDITOR LDA $e401,x ;This prevents garbage when loading up to $bc000
       PHA
       LDA $e400,x
       PHA
RAMOK  RTS

RAMNOK INC 712 ;Add your error handling here, there still is a ROM....
       JMP RAMNOK

       INI LOADER ;Make sure the loader is executed before the main program is loaded

 

Edited by Irgendwer
  • Like 1
  • Thanks 2
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...