It is currently Wed Aug 21, 2019 12:53 pm

All times are UTC - 7 hours



Forum rules





Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sat Apr 27, 2019 12:11 pm 
Offline

Joined: Sun Dec 24, 2017 10:16 am
Posts: 17
Hello,

I think tcc65816 provided with Snes SDK has its own version of wla which has been modified to work with it :
https://github.com/optixx/snes-sdk

I would like to upgrade wla (version 9.4) to the latest 9.8.

I tried to compile a simple hello_world (i saw that parameters change) but i get this error :

wla-65816 -v -o hello_world.obj hello_world.asm
Pass 1...
hello_world.asm:53: DIRECTIVE_ERROR: ROM banks == 8, selected bank 127.
hello_world.asm:53: ERROR: Couldn't parse "ram.data".

"make": *** [hello_world.obj] Error 1

asm file generated is like that, it seems to be the same that we get it in old version of wla dx :

Code:
.include "hdr.asm"
.accu 16
.index 16
.16bit
.define __main_locals 0
.section ".text_0x0" superfree
main:
.ifgr __main_locals 0
tsa
sec
sbc #__main_locals
tas
.endif
jsr.l consoleInit
pea.w (0 * 256 + 1)
sep #$20
rep #$20
jsr.l setMode
pla
sep #$20
lda #1
pha
rep #$20
jsr.l bgSetDisable
tsa
clc
adc #1
tas
sep #$20
lda #2
pha
rep #$20
jsr.l bgSetDisable
tsa
clc
adc #1
tas
jsr.l setScreenOn
__local_0:
jsr.l WaitForVBlank
bra __local_0
lda.w #0
sta.b tcc__r0
__local_1:
.ifgr __main_locals 0
tsa
clc
adc #__main_locals
tas
.endif
rtl
.ends
.ramsection "ram.data" bank $7f slot 3
__local_dummy.data dsb 1
.ends
.section ".data" superfree
__local_dummy.data: .db 0
.ends
.section ".rodata" superfree
__local_dummy.rodata: .db 0
.ends

.ramsection ".bss" bank $7e slot 2
__local_dummybss dsb 1
.ends


I guess that it is related to tcc and not wla.

Do you have any informations on how to solve it ?


edit : has been solved today by wla dx developer, it was a bug


Last edited by hoit on Sun Jun 16, 2019 2:34 am, edited 2 times in total.

Top
 Profile  
 
PostPosted: Sat May 18, 2019 11:03 am 
Offline

Joined: Sun Dec 24, 2017 10:16 am
Posts: 17
In fact i still need help :)

I built tcc816 with latest wla dx version. But the initial tcc816 was provided with a special wla dx 9.4 and had some modifications.
Now, i would like to compile a hello world project based on pvsneslib which use files that comes from snessdk.

I created a minimal project to test it directly on windows. The first version is here :

http://s000.tinyupload.com/?file_id=768 ... 7718687994

I removed makefiles and only joined COMMAND_LIST.txt which gives command i used.

The first error i had was :

crt0_snes.obj: crt0_snes.asm:205: PARSE_STACK: Unresolved reference to "__nmi_handler".

it has been solved by renaming __nmi_handler to nmi_handler (because "If you have a label that starts with "__", then it is not visible outside the section / file where it was defined. Not any more with v9.8...")

Then the second error :
crt0_snes.asm:251: PARSE_STACK: Unresolved reference to "__endsection.data".

So i tried the same thing, remove "__" when variable start with (__endsection, __startsection, __endramsection and __startramsection)

but it produce

crt0_snes.obj: crt0_snes.asm:251: PARSE_STACK: Unresolved reference to "endsection.data".

VHelin (wla dx owner) has changed wla dx to include this treatment in the latest commit. This is a new -x parameter that create labels SECTIONSTART_[section name] and SECTIONEND_[section name] (it was specific to wla dx 9.4 version provided with tcc816)

I replaced startsectionxxx and endsectionxxx by the new SECTIONSTART and SECTIONEND.
Then i got a lot of errors of Unresolved reference to xxxxx which came from libc_c.asm. For each, i just removed the "_" or "__" before the name like for nmi_handler. (i don't know what will be the final impact on the rom...)

Now, wlalink.exe linkfile test.sfc produce this error :

crt0_snes.obj: crt0_snes.asm:243: COMPUTE_PENDING_CALCULATIONS: Result (339/$153) of a computation is out of 8-bit range.

crt0_snes.asm line 243 is : sta.b nmi_handler + 2
and nmi_handler is declared like that : nmi_handler dsb 4

I replaced sta.b by sta.w (16 bit constraint) and the same error occurs few lines after. I replaced all lines with this error to use ".w" to finally get :

libm.obj: libm.asm:319: COMPUTE_PENDING_CALCULATIONS: Result (443/$1bb) of a computation is out of 8-bit range.

on this line :

- sty tcc__E - 1,X

This is the final version i uploaded with the latest change i explained :

http://s000.tinyupload.com/?file_id=627 ... 5930283348

Wla 9.8 and 9.4 are differents and this explain some issues but i think constraints with 8/16/24 bits are the same and this "out fo range" are strange.

I am not fluent in asm and not to sure to be on the right way.

Does somebody can help me ?

Thanks


Top
 Profile  
 
PostPosted: Sun Jun 16, 2019 2:44 am 
Offline

Joined: Sun Dec 24, 2017 10:16 am
Posts: 17
I changed a new time the title of this thread to be more precise.

Few modifications have be done in wla 9.8 to solve some bugs and to add new functionalities that were coded for the specific 9.4 version used with tcc816 and snessdk.

I think that wla 9.8 and tcc816 are now ready to work but i need to upgrade sources of PVSneslib (based on snes sdk) to get it working.

I did it in different files and the code now build correctly BUT, nothing that need to be display works (background, sprites, text...)
I investigated on it but i don't know where it comes from. the "main" function of sample code is equivalent to this C code :

Code:
#include <snes/console.h>

int main(void) {
   consoleInit();
   setMode(BG_MODE1,0);  bgSetDisable(1);  bgSetDisable(2);

   setScreenOn();
   
   consoleNocashMessage("test");
   
   while(1) {
      WaitForVBlank();
   }
   return 0;
}


So when the rom is launched, we should get "test" in No$sns TTY Debug Window but it is not the case.
consoleNocashMessage function is defined in consoles.asm

I created a sample that reproduce it with all .asm files necessary (lot of files are provided to build correctly but not used in this sample) :
http://s000.tinyupload.com/?file_id=850 ... 7262910760

There are only need to execute command lines in COMMAND_LIST.txt to get the rom and i provided the last version of wla but as windows executable only.

if someone has an idea of the issue... :)


Top
 Profile  
 
PostPosted: Thu Jun 20, 2019 12:21 pm 
Offline

Joined: Sun Dec 24, 2017 10:16 am
Posts: 17
New try...
I did a lot of test by reducing the code, replacing names, removing all "_" at the beginning of names, creating unique names for each section but i do not have anymore idea or things to test.

I reduced the hello_world to this code (which work with wla 9.4) :

Code:
#include <snes/console.h>

int main(void) {
   consoleNocashMessage("test");
   
   while(1) {
   }
   return 0;
}


When everything is converted to asm code, i think the entry point is tcc_start in crt0_snes.asm :
Code:
tcc__start:
    ; Initialize the SNES.
    sei             ; Disabled interrupts
    clc             ; clear carry to switch to native mode
    xce             ; Xchange carry & emulation bit. native mode
    rep     #$18    ; Binary mode (decimal mode off), X/Y 16 bit
    ldx     #$1FFF  ; set stack to $1FFF
    txs

    jsr tcc__snesinit

    rep #$30   ; all registers 16-bit

    ; direct page points to register set
    lda.w #tcc__registers
    tad

    lda.w #EmptyNMI
    sta.b nmi_handler
    lda.w #:EmptyNMI
    sta.b nmi_handler + 2

    ; copy .data section to RAM
    ldx #0
-   lda.l SECTIONSTART_.data,x
    sta.l SECTIONSTART_ram.data,x
    inx
    inx
    cpx #(SECTIONEND_.data-SECTIONSTART_.data)
    bcc -

    ; set data bank register to bss section
    pea $7e7e
    plb
    plb

    ; clear .bss section
    ldx #(((SECTIONEND_.bss-SECTIONSTART_.bss) & $fffe) + 2)
    beq +
-   dex
    dex
    stz.w $2000, x
    bne -
+


    ; used by memcpy
    lda #$0054 ; mvn + 1st byte
    sta.b move_insn
    lda #$6000 ; 2nd byte + rts
    sta.b move_insn + 2

    ; used by memmove
    lda #$0044 ; mvp + 1st byte
    sta.b move_backwards_insn
    lda #$6000 ; 2nd byte + rts
    sta.b move_backwards_insn + 2

    pea $ffff - SECTIONEND_ram.data
    pea :SECTIONEND_ram.data
    pea SECTIONEND_ram.data
    jsr.l malloc_init
    pla
    pla
    pla

    stz.b tcc__r0
    stz.b tcc__r1

    jsr.l main

    ; write exit code to $fffd
    lda.b tcc__r0
    sep #$20
    sta $fffd
    rep #$20
    stp
.ends


Then main is like that (declared in hello_world.asm) :
Code:
.section ".text_0x0" superfree
main:
.ifgr __main_locals 0
tsa
sec
sbc #__main_locals
tas
.endif
pea.w :tccs_L.5
pea.w tccs_L.5 + 0
jsr.l consoleNocashMessage
tsa
clc
adc #4
tas
__local_0:
bra __local_0
lda.w #0
sta.b tcc__r0
__local_1:
.ifgr __main_locals 0
tsa
clc
adc #__main_locals
tas
.endif
rtl
.ends



tccs_L.5 contains the word "test" given to parameter in consoleNoCashMessage :

Code:
.section ".rodata" superfree
tccs_L.5: .db $74,$65,$73,$74,$0
.ends


And the consoleNocashMessage function (in consoles.asm) :

Code:
; void consoleNocashMessage(const char *message);
consoleNocashMessage:
   php
   phb
   
   sep   #$20
   lda #$0
   pha
   plb ; change bank address to 0
   
   rep   #$20
   phy
   
   ldy #$0
   
   ; Let tcc__r2 point to the message
   lda      8,s
   sta      tcc__r2
   lda      10,s
   sta      tcc__r2h
   
   sep   #$20
-:   lda      [tcc__r2],y
   beq +
   iny
   sta.l   REG_DEBUG
   bra -
   
+:   ply
   plb
   plp
   rtl


I guess that wla 9.8 is used by other people to create snes game...


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 6 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