It is currently Thu Apr 19, 2018 7:23 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: MMC64 boot.bin
PostPosted: Sun Aug 03, 2008 1:10 am 
Offline

Joined: Sun Aug 03, 2008 12:52 am
Posts: 7
I have a SuperSnapshot freeze PRG image that I'm trying to load as a boot.bin on the MMC64. The freeze PRG is a machine language loader with a BASIC wrapper (10 SYS2061). I modified the PRG so that it starts using machine language (JMP 2061) instead of the BASIC startup, but it doesn't work as a boot.bin.

I've written cartridge programs before (just running from simple 8k EPROM carts) and I know that you have to initialize some of the kernal routines to use the built-in keyboard scanner and other standard system stuff. I tried including the same startup code I've used in my other carts in boot.bin, but it appears to lock up when initializing the screen/keyboard. Below is what I'm currently using and does not work.

sei
jsr $FF84 ; initialize I/O devices
jsr $FF87 ; initalise memory pointers
jsr $FF8A ; restore I/O vectors
jsr $FF81 ; initalise screen and keyboard
cli
jmp 2061 ; go to start of freeze image loader


Top
 Profile  
Reply with quote  
 Post subject: Re: MMC64 boot.bin
PostPosted: Mon Aug 04, 2008 7:18 pm 
Offline

Joined: Sun Aug 03, 2008 12:52 am
Posts: 7
Made some progress. I figured out that because it was a BASIC program and I was adding machine code on to the front of it which was in the screen character area, the video/IO initialization clears the screen which then trashes my program. I modified the program to copy itself into a different area of memory and run from there.

However the freeze program is still not working. My theory is that it expects BASIC to be initialized, so I'm trying to figure out how to do that. I tried just running the BASIC init kernal calls but that doesn't work -- I end up with a READY prompt that spews garbage when I type any BASIC commands. Anybody know how to fully initialize BASIC from startup using machine code but retain control of the system?


Top
 Profile  
Reply with quote  
 Post subject: Re: MMC64 boot.bin
PostPosted: Tue Aug 05, 2008 10:03 am 
Offline

Joined: Sun Aug 03, 2008 12:52 am
Posts: 7
It seems like at the very least, just running code should reset the computer and start BASIC from the boot.bin, but it does not. Anybody have any idea what I'm missing?

; disable MMC64
lda #$55
sta $df13
asl
sta $df13
lda #$FF
sta $DF11

jmp $e394 ; full reset


Top
 Profile  
Reply with quote  
 Post subject: Re: MMC64 boot.bin
PostPosted: Wed Aug 06, 2008 6:01 pm 
Offline
Site Admin

Joined: Wed Jan 11, 2006 12:22 pm
Posts: 860
I don't see where you're doing any bank switching. Are you sure the memory map is correct?


Top
 Profile  
Reply with quote  
 Post subject: Re: MMC64 boot.bin
PostPosted: Thu Aug 07, 2008 4:42 am 
Offline

Joined: Sun Aug 03, 2008 12:52 am
Posts: 7
I'm sorry but I don't understand your comment on bankswitching, could you clarify?

I did check that address 1 (6510 On-Chip 8-Bit Input/Output Register) is set to the same value when it boots from the MMC64 as it is when the system boots to BASIC, which is $37 -- this enables the BASIC ROM, I/O, and the KERNAL ROM.


Top
 Profile  
Reply with quote  
 Post subject: Re: MMC64 boot.bin
PostPosted: Fri Aug 08, 2008 1:13 pm 
Offline
Site Admin

Joined: Wed Jan 11, 2006 12:22 pm
Posts: 860
Errhm.. sorry for not reading carefully before..

Are you sure this call is being decimal in your assembler? If not you're actually doing a SYS 8289 here:
Quote:
jmp 2061 ; go to start of freeze image loader



Try jmp $080d instead.


Top
 Profile  
Reply with quote  
 Post subject: Re: MMC64 boot.bin
PostPosted: Sat Aug 09, 2008 3:12 am 
Offline

Joined: Sun Aug 03, 2008 12:52 am
Posts: 7
yeah, it's DASM -- it definitely considers it decimal if you don't put a dollar sign (I had a bug in another program the other day from a missing $)

I've been disassembling the boot.bin from some of the other MMC64 utils to see what I can figure out. Wish the source code was available. I found the source for an early version of the MMC64 loader, but it didn't tell me much I didn't already know.

I feel like I'm missing something obvious -- this shouldn't be a very tough problem.


Top
 Profile  
Reply with quote  
 Post subject: Re: MMC64 boot.bin
PostPosted: Sat Aug 09, 2008 6:08 pm 
Offline
Site Admin

Joined: Wed Jan 11, 2006 12:22 pm
Posts: 860
Hmm.. I guess your best bet is to Freeze it after locking up and see where it goes wrong. Ironically it would require you to freeze the freezer :P


Top
 Profile  
Reply with quote  
 Post subject: Re: MMC64 boot.bin
PostPosted: Sat Aug 09, 2008 8:13 pm 
Offline

Joined: Sun Aug 03, 2008 12:52 am
Posts: 7
Ah that's a great idea. Then I can use the CCS64 monitor and other tools to check it out. I've had an MMC64 for a while but I just got a MMC Replay, good way to break it in.


Top
 Profile  
Reply with quote  
 Post subject: Re: MMC64 boot.bin
PostPosted: Tue Aug 12, 2008 6:36 pm 
Offline

Joined: Sun Aug 03, 2008 12:52 am
Posts: 7
I couldn't get the cart to freeze when running boot.bin, but maybe I was doing something wrong. It appears that the main problem I was having is that the MMC64 boot.bin loader uses some memory around $1000 and so loading a BASIC program directly into memory causes bad things to happen. I haven't totally verified that this is why things weren't working, but regardless, the code below works fine. And it could probably be modified to run an actual BASIC program pretty easily (as I said before this is a machine code program with a BASIC wrapper, so I'm bypassing the BASIC part).

Code:
   ; Loads a supersnapshot image at startup
   ; on an MMC64 as boot.bin
   ; Assembled using DASM

   processor 6502

MEMCPY equ $C000
srcptr equ 34
destptr equ 36

   ; It appears that the MMC64 bootup copier places itself in
   ; memory below this, so if you load into the normal BASIC
   ; area then bad things happen.
   org $1FFE
   word $2000

   ; copy setup code into high memory
   ldx #0
copyloop:
   lda startup,x
   sta MEMCPY,x
   dex
   bne copyloop
   jmp MEMCPY
   
startup:
   rorg MEMCPY
   ; disable MMC64
   lda   #$55
   sta   $df13
   asl
   sta   $df13
   lda #$FF
   sta $DF11

   sei

   lda #2
   sta 53280
   sta 53281

   ; init system to the state it would
   ; be in after a normal boot
   ;*********************************************
   ldx #$FF
   sei
   txs
   cld
   stx $d016
   jsr $FF84 ; initialize I/O devices
   jsr $FF87 ; initalise memory pointers
   jsr $FF8A ; restore I/O vectors
   jsr $FF81 ; initalise screen and keyboard
   cli

   lda #15
   sta 53280
   sta 53281

   jsr $E453 ; initialize BASIC vector
   jsr $E3BF ; init BASIC
;   jsr $E422 ; print BASIC startup message
   ;*********************************************

   ; setup pointers to copy program into BASIC memory space
   lda #<(bottom+2)
   sta srcptr
   lda #>(bottom+2)
   sta srcptr+1
   lda #$01 ; BASIC
   sta destptr
   lda #$08 ; BASIC
   sta destptr+1

   ; copy program into BASIC memory
   ldy #0
mikeCopy:
   lda (srcptr),y
   sta (destptr),y
   inc srcptr
   bne noCarry1
   inc srcptr+1
noCarry1
   inc destptr
   bne noCarry2
   inc destptr+1
noCarry2
   lda srcptr
   cmp #<top
   bne mikeCopy
   lda srcptr+1
   cmp #>top
   bne mikeCopy

   lda #0
   sta 53280
   jmp 2061 ; go to start of freeze loader

   org $2080
   rorg $2080
bottom:
   incbin final9.prg
top:



Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group