retrohackers.com
http://www.retrohackers.com/

Cartidge (BIN) to Load First File on Disk
http://www.retrohackers.com/viewtopic.php?f=8&t=500
Page 1 of 1

Author:  mistermsk [ Wed Aug 19, 2009 8:52 pm ]
Post subject:  Cartidge (BIN) to Load First File on Disk

Hi All,

I have everything to write a BIN file to a cartridge except for one thing. The knownledge to program a cartidge.

Does anyone have a standard 8k CRT (Which I can rip out the added code at the beginning) or BIN file that just loads and runs the first file on device 8?

Like this:
LOAD":*",8:RUN

or
LOAD"MENU",8:RUN

Thanks,
MisterMsk

Author:  mistermsk [ Thu Aug 20, 2009 6:33 pm ]
Post subject:  Re: Cartidge (BIN) to Load First File on Disk

So, I am actually going to be putting this on my MMC Reply card so when I press number 6, it will load MENU (to make it easier) and run it off of device 8.

I found this here which can be used to autostart a cartridge. I just need to load a program by the name MENU and run it.

Author:  mistermsk [ Sat Aug 22, 2009 1:13 am ]
Post subject:  Re: Cartidge (BIN) to Load First File on Disk

Ok... So working on stuff, I read about the ROMaker (ROMBuilder). So through trial and error I made the file attached. My main goal was to auto browse the directory with sb2brwse on device 8. I also use guruterm and warpcopy a lot. This puts everything in one ROM for the MMC Replay. Please not I only tested it on v0.54. Also, in the options menu of the MMC Replay I change the ROM from none to the number I flashed. I also put the C64 MMC MENU to NO. This way it just boots up to the ROM. I seldom use my MMC replay to launch files.

Someone asked me why have the MMC replay if you are not going to use the SD Card slot. Easy, I use it to auto-boot this ROM. I also like the 512K REU that it has. Finally, I like the RR-Net card it has attached. This way there is no flipping swithes or anything. It loads the menu up. I select sb2brwse and I can play my games on my uIEC.

I uploaded it so other can share in this if they have a MMC replay cartridge.

Attachments:
File comment: Boot ROM for MMC Replay with sd2brwse, dracopy, guruterm, and warpcopy. (tested on v.054 only).
mmcreplayboot.zip [28.8 KiB]
Downloaded 504 times

Author:  RaveGuru [ Mon Aug 24, 2009 3:35 pm ]
Post subject:  Re: Cartidge (BIN) to Load First File on Disk

Nice one!
You might wanna put a copy under the File section as well.

A cartridge ROM is actually very simple to make. The start address is $8000 and should start with the cold start vector, then the warm start vector, followed by the letters (bytes) CBM80 if the cart should autostart. There's a good article on CB64 here: http://codebase64.org/doku.php?id=base: ... _cartridge

Keep 'em coming! :wink:

Author:  mistermsk [ Mon Aug 24, 2009 4:04 pm ]
Post subject:  Re: Cartidge (BIN) to Load First File on Disk

Thanks. I messed with the ROMBuild.asm file and found by changing it around, I acually can have it auto-boot a PRG file (as long as it is small enough and starts at $0801.) Anyway, I found when I autostarted sb2brwse, it was to fast for the uIEC. It shows misc. characters. How I found out, I use the rom above and press the number one right aware. Boom, garbage charaters. If I waited a few seconds then hit one, it worked fine. So, I am looking at a way to create a pause. On Lemon64 I asked and they said to use a loop that looks at IRQs/rasters. Hmmm... I tried what they said but it just hangs, no matter where I put it in. Everything works up to that point, then it hangs.

Code Provided by PeteD at Lemon64
Code:
         ldx #50*3  ;50 fps * 3 seconds
         lda #128
loop1 cmp $d012      ;check if the raster has reached line 128
         bne loop1      ;no, so keep checking
loop2 cmp $d012      ;if it has you want to make sure you dont catch it more than once per frame
         beq loop2      ;so wait till it isn't 0 any more
         dex
         bne loop1      ;loop round 50*3 times


Since I am pretty new at the assembly gig, any one have any other examples on how to pause (or put a wait) in the program? Look for about a 3 second wait.

Thanks for All Your Help,
MisterMsk

Author:  RaveGuru [ Mon Aug 24, 2009 5:40 pm ]
Post subject:  Re: Cartidge (BIN) to Load First File on Disk

The above code should do the trick. I suspect the problem is before and/or after the above code. Perhaps the above code thrashes something. Paste all the code so we can take a look.

Author:  Alex [ Mon Sep 07, 2009 11:52 pm ]
Post subject:  Re: Cartidge (BIN) to Load First File on Disk

Maybe a bit late but here is my solution the the problem in dreamass format:

Code:
#ifndef bin

#segdef "crtheader"    , $0000-$0040
#segdef "chippacket"   , $0040-$0050
#segdef "cbmheader"   , $8000-$8009
#segdef "cartcode"   , $8009-$A000, fillup, force

#outfile "loader.crt", "crtheader", "chippacket", "cbmheader", "cartcode"

#else


#segdef "cbmheader"   , $8000-$8009
#segdef "cartcode"   , $8009-$A000, fillup, force

#outfile "loader.bin", "cbmheader", "cartcode"

#endif

#ifndef bin

.segment "crtheader"
   .text "c64 cartridge   "   ;3 spaces are required!!!
   .byte $00,$00          ;header length
   .byte $00,$40          ;header length
   .word $0001          ;version
   .word $0000          ;crt type
   .byte $00          ;exrom line
   .byte $01          ;game line
   .byte $00,$00,$00,$00,$00,$00    ;unused
   .text "crt first file loader                          " ;must be 32 bytes
   .byte 0


.segment "chippacket"
   .text "chip"
   .byte $00,$00,$20,$10 ;chip length
   .byte $00,$00 ;chip type = ROM
   .byte $00,$00 ;bank = normal cartridge
   .byte $80,$00 ;address
   .byte $20,$00 ;length

#endif

.segment "cbmheader"
   * = $8000

cartheader:
   .word hardstart   ;$09, $08
   .word warmstart   ;$09, $08
   .byte $c3, $c2, $cd, $38, $30

.segment "cartcode"
   
hardstart:
   stx $d016   ;enable VIC take a look at kernal $fCef
   
   jsr $fda3   ;init i/o
   jsr $fd50   ;init system constants
   jsr $fd15   ;restore kernal vectors
   jsr $ff5b   ;CINT - init vic and screen editor
   

warmstart:
   ;basic reset
   jsr $e453
   jsr $e3bf
   jsr $e422
   ldx #$fb
   txs
   


loader:
   lda $d011
   and #%11101111 ;blank screen
   sta $d011

   ldx #$00
rel   lda mcode, x
   sta $0400, x
   inx
   bne rel

   jmp $0400

mcode:
   .pseudopc $0400
   
   sei
   lda #$37
   sta $01
   cli
   
   lda #fname_end-fname
        ldx #<fname
        ldy #>fname
        jsr $ffbd     ; call SETNAM
        lda #$01
        ldx $ba       ; last used device number
        bne skip
        ldx #$08      ; default to device 8
skip:   ldy #$01      ; not $01 means: load to address stored in file
        jsr $ffba     ; call SETLFS

        lda #$00      ; $00 means: load to memory (not verify)
        jsr $ffd5     ; call LOAD

   jmp $0960   ;default exomizer entry point
error:
   jmp *

fname:   .text "*"
fname_end:
   .realpc

end:          


I use it to run prgs crunched with exomizer. There is no real error handling and the entrypoint of loaded program is hardcoded but it is trivial to change the code to your needs. Also using $0400 might not be the best idea - stack can be better in some cases. Actually as long as you are using 8kb crt from $8000 you can safely use kernal calls anyway so there is no need to relocate loader code. Treat it as a very poor example for further reference.

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/