It is currently Sun Oct 22, 2017 10:34 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: ca65 Mystical Problem ;)
PostPosted: Thu Sep 15, 2005 8:28 pm 
Hi, i'm from argentina and i need help with some stuff that i cannot understand with a difference that i found between the files that i assembled with two diferents assemblers.
(Ah, btw, sorry for my bad english, if you don't understand something, i'll try to explain my thoughts in a better (or diferent) way) :)

Ok, this is the problem.

I was coding in NESASM for a while and without problems, when i realized that exist a REAL assembler called ca65 (from cc65.org).

I was very happy with my discover until i began having serious problems with it.

The same code (NesASM code and ca65 code) put the exact SAME info in the .nes file, but only ONE byte changes between them.

It's the mysterious byte $80 at $40D0, that nesasm put in the .nes file and ca65 not. Obiously i'm doing something wrong and i can't figure out where is the problem.

I'm going to put here my config file for ca65 and my source code:


Code:
# romstruct.cfg (for the linker)
# Distribucion de SEGMENTos la ROM de Nintendo
# Alekhine d-phenze

# Asignacion de cachos de memoria
MEMORY
{
   ZP:
      start   $02
      size   $1A
      type   rw
      define   yes;

   # Header iNES
   HEADER:
      start   $00
      size   $10
      file   %O
      fill   yes;
   
   # 2 bancos ROM de 16kb
   # - startup
   # - code   
   # - rodata
   # - data (load)

   BANK0:   
      start   $8000
      size   $7FF4   
      file   %O
      fill   yes
      define   yes;

   # Vectores de Hardware al final
   # de el segundo ROM de 2kb
   BANK1:
      start   $FFF4
      size   $C
      file   %O
      fill   yes;

   # 1 Banco CHR de 8kb
   CHRBANK:
      start   $0000
      size   $2000
      file   %O
      fill   yes;

   # SRAM 2k standard (-zeropage)
   # $0100-$0200 cpu stack
   # $0200-$0500 3 paginas para el buffer de escritura de la PPU
   # $0500-$0800 3 paginas para stack de parametros de cc65
   SRAM:
      start   $0500
      size   $0300
      define   yes;
      
   # SRAM banco 8k adicionales
   # - data (run)
   # - bss
   # - heap
   RAM:
      start   $6000
      size   $2000
      define   yes;

}

# Estructura de la ROM de Nintendo

SEGMENTS {
    HEADER:   load = HEADER,           type = wprot;
    STARTUP:  load = BANK0,            type = wprot, define = yes;
    CODE:     load = BANK0,            type = wprot, define = yes;
    RODATA:   load = BANK0,            type = wprot, define = yes;
    DATA:     load = BANK0, run = RAM, type = rw,    define = yes;
    VECTORS:  load = BANK1,            type = rw;
    CHARS:    load = CHRBANK,          type = rw;
    BSS:      load = RAM,              type = bss,   define = yes;
    ZEROPAGE: load = ZP,               type = zp;
}

FEATURES {
    CONDES: segment = RODATA,
       type = constructor,
       label = __CONSTRUCTOR_TABLE__,
       count = __CONSTRUCTOR_COUNT__;
    CONDES: segment = RODATA,
       type = destructor,
       label = __DESTRUCTOR_TABLE__,
       count = __DESTRUCTOR_COUNT__;
}

SYMBOLS {
    __STACKSIZE__ = $0300;     # Stack de 3 paginas
}
   


here goes now my source code:

Code:

; -
; Work.asm
; -
; Alekhine d-phenze*
; Para CC65 (ca65.exe & ld65.exe), Nintendo
; -
; Consta de los siguientes archivos:
; ----------------------------------
;   % romstrct.cfg (Estructura del rom)
;   % work.asm (este archivo)
;   % make.bat (crea la rom)
; ----------------------------------
;
; Esto genera algo en pantalla, demostrando
; que esta configuracion genera la ROM nes :)
; o sea, si anda, tenemos una rom Nes para
; codear ;)

; ******************************************************
; Header iNES 10 bytes
; ******************************************************

.SEGMENT "HEADER"
.byte   $4e, $45, $53, $1a   ; 'NES' + 1A
.byte   $01         ; 16kb PRG-ROM Numero de paginas
.byte   $01         ; 8kb  CHR-ROM Numero de paginas
.byte   $01         ; Byte de control de la Rom #1
.byte   $00         ; Byte de control de la Rom #2
            ; Byte #1: $MO
            ; M Define el numero de mapper
            ; O Define las opciones de la rom.
            ; El byte #2 es preferible
            ; dejarlo en $00 hasta ahora
.byte   $00, $00, $00, $00   ; Muchos ceros
.byte   $00, $00, $00, $00   ; muchos ceros mas

.SEGMENT "CODE"
STARTUP = $80
; *****
; This is a routine ONLY to make sure that it worked in a
; random emulator
; *****

   lda #%00001000      ; Los seteos se pueden
   sta $2000      ; ver en documentos
   lda #%01011110      ; tecnicos sobre el PPU
   sta $2001

; sonido


   lda #$FF   ; typical
   sta $4000  ; write

   lda #%11011011  ; % means binary number, remember the '#' for immediate values.
   sta $4001  ; immediate means "not an address, just a number".

   lda #$A5
   sta $4002

   lda #$AB
   sta $4003

   lda #%00000001
   sta $4015

infinito:
   jmp infinito


.SEGMENT "CODE"

.SEGMENT "RODATA"

;********
; Here i put garbage for viewing where the linker put
; the info in the binary file
; i comment the .byte statament where are garbage
; every time i compile the source
;********
.byte $AA,$AA,$AA    ; Basura para identificar
         ; segmentos
.SEGMENT "DATA"
ourpal: .incbin "our.pal"
.byte $BB,$BB,$BB    ; Basura para identificar
         ; segmentos

.SEGMENT "VECTORS"
.word 0      
.word STARTUP
.word 0         ; Basura para identificar
         ; segmentos



.SEGMENT "CHARS"

.incbin   "our.bkg"
.incbin   "our.spr"


.SEGMENT "BSS"


; *** more garbage, remember, i comment this
;       before compile
; i use these bytes to trace where the linker put the info
; in the final binary
.byte $EE,$EE,$EE   ; Basura para identificar
         ; segmentos
      


and now, the .bat

Code:
ca65 work.asm
ld65 -C romstrct.cfg work.o
copy /Y a.out work.nes


Ok, when i compile this, the ca65 make a exact .nes with the .nes
that i make with nesasm

Any clue? :(

tnx for your time =)


Top
  
 
PostPosted: Thu Sep 15, 2005 8:41 pm 
Offline

Joined: Thu Sep 15, 2005 8:34 pm
Posts: 5
now i have an account here =)
i'm gonna rewrite this because its bad written
Anonymous wrote:

Ok, when i compile this, the ca65 make a exact .nes with the .nes
that i make with nesasm

Any clue? :(

tnx for your time =)


i meant to say something like this:

"Ok, when i compile this, the ca65 make an exact .nes with the .nes that
i make with nesasm, but the diference is a byte.
Here are the values:

Nesasm: Byte 80 in 40D0
ca65: Byte 00 in 40D0

The .nes that doesn't work is the one compiled with ca65"

there go =)

_________________
---------
x86 democoding
ok, that's odd
6502 democoding
that's insane ;)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 16, 2005 12:52 am 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3471
Location: Indianapolis
Is it your STARTUP label in the code?

You have STARTUP = $80
And your reset vector is .WORD STARTUP
That might make it reset at $0080 instead of $8000. But $40D0 isn't where the reset vector would be, wouldn't that be in the CHR?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 16, 2005 4:52 am 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
I think the values are offsets into the .nes file.

Quote:
Nesasm: Byte 80 in 40D0
ca65: Byte 00 in 40D0


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 18, 2005 7:52 pm 
Offline

Joined: Thu Sep 15, 2005 8:34 pm
Posts: 5
Memblers wrote:
Is it your STARTUP label in the code?

You have STARTUP = $80
And your reset vector is .WORD STARTUP
That might make it reset at $0080 instead of $8000. But $40D0 isn't where the reset vector would be, wouldn't that be in the CHR?


No, it isn't.
_But_ the $80 or $8000 value must go in addr 400D to work (it's wrong what i said before about the addr, 40D0. It's 400D.
So, value $80 in addr $400D in the rom.

I have the same problem with c64 prgs.
I don't understand how, where and when put the "go here and execute" value to make my code work.
Any clue or documentation? =)

_________________
---------
x86 democoding
ok, that's odd
6502 democoding
that's insane ;)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 18, 2005 7:56 pm 
Offline

Joined: Thu Sep 15, 2005 8:34 pm
Posts: 5
blargg wrote:
I think the values are offsets into the .nes file.

Quote:
Nesasm: Byte 80 in 40D0
ca65: Byte 00 in 40D0


where do you think that i must put the offsets to make my rom work?

i think that i'm missing something in the documentation, tutorials or manuals, and it's only for a language problem, because i usually don't have problems with coding.
I code in c, c++, opengl, php, assembly x86, etc and all the english stuff worked fine for me.

probably i missed something.. :/

_________________
---------
x86 democoding
ok, that's odd
6502 democoding
that's insane ;)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 18, 2005 8:28 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1389
Change "STARTUP = $80" to "STARTUP:" and it should work correctly.

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 18, 2005 11:04 pm 
Offline

Joined: Thu Sep 15, 2005 8:34 pm
Posts: 5
Quietust wrote:
Change "STARTUP = $80" to "STARTUP:" and it should work correctly.


mmhh.. i though about that but the output file was
exactly the same, so that
doesn't seems to work :/

anyone has these files working?

the .cfg and the .asm doing something?

_________________
---------
x86 democoding
ok, that's odd
6502 democoding
that's insane ;)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 18, 2005 11:18 pm 
Offline

Joined: Thu Sep 15, 2005 8:34 pm
Posts: 5
Maybe, a screenshot could help.

Image

if phpbb doesn't show the screenshot, here is too
http://www.iflashera.com.ar/~futacast/deposito/cual_es_el_problema.jpg

tnx for your patience

_________________
---------
x86 democoding
ok, that's odd
6502 democoding
that's insane ;)


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 5 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:  
Powered by phpBB® Forum Software © phpBB Group