Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Help with WLA-DX Multi File Project

Reply to topic
Author Message
  • Joined: 14 Apr 2024
  • Posts: 4
  • Location: Germany
Reply with quote
Help with WLA-DX Multi File Project
Post Posted: Fri May 03, 2024 3:44 am
Last edited by Retro-Hax on Fri May 03, 2024 7:27 am; edited 2 times in total
So this may seem a bit weird and may just be my Stupidity but as i come from a C Background where obviously you dont write your entire Project in one single C File as ive seen a lot in ASM actually i decided to use and what was recomenned WLA-DX and when trying to split just the basic Hello World Example into Multiple Files the Assembler just gives me an error which prevents me from doing my work :((((

sms.inc

; SMS defines
.define VDPControl $bf
.define VDPData $be
.define VRAMWrite $4000
.define CRAMWrite $c000


init.asm

.include "inc/sms.inc" ONCE

; WLA-DX banking setup
.memorymap
defaultslot 0
slotsize $8000
slot 0 $0000
.endme

.rombankmap
bankstotal 1
banksize $8000
banks 1
.endro

; SDSC tag and SMS rom header
.sdsctag 1.0,"Super Mario Land","Super Mario Land","Retro-Hax"

.bank 0 slot 0
.org $0000
.section "Boot section" force
; Boot section
    di              ; disable interrupts
    im 1            ; Interrupt mode 1
    jp init         ; jump to init program
.ends

; Init Hardware
init:
    ld sp, $dff0

    ; Set up VDP registers
    ld hl,VDPData
    ld b,VDPDataEnd-VDPData
    ld c,VDPControl
    otir

    ; Clear VRAM
    ; Set VRAM write address to 0 by outputting $4000 ORed with $0000
    ld a,$00
    out (VDPControl),a
    ld a,$40
    out (VDPControl),a
    ; Output 16KB of zeroes
    ld bc, VRAMWrite ; Counter for 16KB of VRAM
    ClearVRAMLoop:
        ld a,$00 ; Value to write
        out (VDPData),a ; Output to VRAM address, which is auto-incremented after each write
        dec bc
        ld a,b
        or c
        jp nz,ClearVRAMLoop
    jp main


main.asm

.include "src/init.asm" ONCE

main:
    jp main


pause.asm

.org $0066
.section "Pause button handler" force
; Pause button handler
    retn
.ends


Decided to add the Errror from WLA-DX

$ make
wla-z80  -o build/init.o src/init.asm
wla-z80  -o build/main.o src/main.asm
wla-z80  -o build/pause.o src/pause.asm
PHASE_2: INCLUDE_DIRECTIVES: ROMBANKS/ROMBANKMAP wasn't defined.
make: *** [Makefile:24: build/pause.o] Error 1
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14755
  • Location: London
Reply with quote
Post Posted: Fri May 03, 2024 7:09 am
What are your command lines and error messages?
  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2012
  • Posts: 889
  • Location: Spain
Reply with quote
Post Posted: Fri May 03, 2024 7:16 am
I saw in Discord that you already solved most of the issues, but your current error message is because you're using VDPDataEnd, and you have not defined it. It should point at the end of the data you want to send to the VDP, as it's used here:
; Set up VDP registers
    ld hl,VDPData
    ld b,VDPDataEnd-VDPData
    ld c,VDPControl
    otir
  View user's profile Send private message
  • Joined: 14 Apr 2024
  • Posts: 4
  • Location: Germany
Reply with quote
Post Posted: Fri May 03, 2024 7:22 am
Maxim wrote
What are your command lines and error messages?


uh so this is now lots of time later but basically i am getting this error now
```
$ make
wla-z80 -o build/init.o src/init.asm
wla-z80 -o build/main.o src/main.asm
wla-z80 -o build/pause.o src/pause.asm
PHASE_2: INCLUDE_DIRECTIVES: ROMBANKS/ROMBANKMAP wasn't defined.
make: *** [Makefile:24: build/pause.o] Error 1
```
but i will update the post now
  View user's profile Send private message Visit poster's website
  • Joined: 06 Mar 2022
  • Posts: 681
  • Location: London, UK
Reply with quote
Post Posted: Fri May 03, 2024 8:59 am
Last edited by willbritton on Fri May 03, 2024 9:25 am; edited 1 time in total
Presumably you're past this already, and Maxim alluded to the answer in Discord:

Quote
Some parts of the environment setup need to be common to all files, like the memory map, so you have to include those parts in every file


Also worth noting that you don't have to approach this as assembling multiple modules separately. Instead you could write all your code as "include" files, have your "main.asm" include everything else directly or indirectly, and then use a single wla-z80 -o ... src/main.asm command to assemble a single object file which you then link.

This might be easier for you to manage in terms of code structure for a single game, and it may also allow the assembler to drop more unused sections as it can reason about the whole assembly rather than chunks in isolation.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3856
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Fri May 03, 2024 9:04 am
willbritton wrote
Also worth noting that you don't have to approach this as assembling multiple modules separately. Instead you could write all your code as "include" files, have your "main.asm" include everything else directly or indirectly, and then use a single wla-z80 -o ... src/main.asm command to compile a single object file which you then link.

This might be easier for you to manage in terms of code structure for a single game, and it may also allow the assembler to drop more unused sections as it can reason about the whole assembly rather than chunks in isolation.


I second this. It's way easier this way - multiple files, single compiled unit.
  View user's profile Send private message Visit poster's website
  • Joined: 14 Apr 2024
  • Posts: 4
  • Location: Germany
Reply with quote
Post Posted: Fri May 03, 2024 12:44 pm
sverx wrote
willbritton wrote
Also worth noting that you don't have to approach this as assembling multiple modules separately. Instead you could write all your code as "include" files, have your "main.asm" include everything else directly or indirectly, and then use a single wla-z80 -o ... src/main.asm command to compile a single object file which you then link.

This might be easier for you to manage in terms of code structure for a single game, and it may also allow the assembler to drop more unused sections as it can reason about the whole assembly rather than chunks in isolation.


I second this. It's way easier this way - multiple files, single compiled unit.


Okay Thank You! :D
Now uh i basically have a game.asm file and my command is well this :P

wla-z80 -o build/game.o game.asm wlalink -r -d -v -S game.ld build/bin/game.sms

but it does not work at all :((((
like i only get the wla-link usage screen
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3856
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Fri May 03, 2024 12:54 pm
you still have to assemble and link separately, so likely:

wla-z80 -o build/game.o game.asm
wlalink -r -d -v -S game.ld build/bin/game.sms
  View user's profile Send private message Visit poster's website
  • Joined: 14 Apr 2024
  • Posts: 4
  • Location: Germany
Reply with quote
Post Posted: Fri May 03, 2024 1:00 pm
sverx wrote
you still have to assemble and link separately, so likely:

wla-z80 -o build/game.o game.asm
wlalink -r -d -v -S game.ld build/bin/game.sms


yup i feel so dumb X_X

make
wla-z80  -o build/game.o game.asm
inc/sms.inc:2: DIRECTIVE_ERROR: "VDPControl" was defined for the second time.
inc/sms.inc:2: ERROR: Couldn't parse ".define".
make: *** [Makefile:18: make] Error 1


Now it works but uh that dumb VDPControl define is still giving me issues :((((
  View user's profile Send private message Visit poster's website
  • Joined: 06 Mar 2022
  • Posts: 681
  • Location: London, UK
Reply with quote
Post Posted: Fri May 03, 2024 1:13 pm
Are you including sms.inc twice?
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!