clth Posted May 1, 2023 Share Posted May 1, 2023 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. Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted May 1, 2023 Share Posted May 1, 2023 Are you using a custom link file? Quote Link to comment Share on other sites More sharing options...
clth Posted May 1, 2023 Author Share Posted May 1, 2023 13 minutes ago, Wrathchild said: Are you using a custom link file? Do you mean linker config file for LD65? Yes, I've attached it. linker.cfg Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted May 1, 2023 Share Posted May 1, 2023 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. 1 Quote Link to comment Share on other sites More sharing options...
clth Posted May 3, 2023 Author Share Posted May 3, 2023 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. Quote Link to comment Share on other sites More sharing options...
baktra Posted May 4, 2023 Share Posted May 4, 2023 A practical example, how I did it for one of my older production. https://github.com/baktragh/train3ose/blob/master/train_routines.asm Refer to the "pre-initialization" code. How I included it in the .cfg file: https://github.com/baktragh/train3ose/blob/master/linker.cfg 1 Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted May 4, 2023 Share Posted May 4, 2023 42 minutes ago, baktra said: Refer to the "pre-initialization" code. Curious why you opted for .byte and not .word here? .word INITAD .word INITAD+1 train_preinit_ivector: .byte <train_preinit,>train_preinit Quote Link to comment Share on other sites More sharing options...
Rybags Posted May 4, 2023 Share Posted May 4, 2023 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. Quote Link to comment Share on other sites More sharing options...
baktra Posted May 4, 2023 Share Posted May 4, 2023 1 hour ago, Wrathchild said: Curious why you opted for .byte and not .word here? .word INITAD .word INITAD+1 train_preinit_ivector: .byte <train_preinit,>train_preinit I don't have any explanation 1 Quote Link to comment Share on other sites More sharing options...
Irgendwer Posted May 6, 2023 Share Posted May 6, 2023 (edited) 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 May 6, 2023 by Irgendwer 1 2 Quote Link to comment Share on other sites More sharing options...
woj Posted May 6, 2023 Share Posted May 6, 2023 20 hours ago, Irgendwer said: The code from @JAC! is also worth mentioning: (https://www.wudsn.com/index.php/productions-atari800/tutorials/tips) So grateful for pointing this out, it has just ended up in my game initialization code 😉 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.