Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2018-07-20 23:54:43

_Q_
Member
Registered: 2018-07-20
Post 1/10

Can't compile Gen. II graphics hack for Yellow

Hi, folks!

I'm new to the Pokemon disassemblies, and I'm having some difficulty. I've been able to compile Pokemon Yellow, but I'm getting an error when I try to compile the Gen. II Graphics hack, which is what I'd like to use as the base for the hack I'm working on.

When I try to compile the ROM, I get the following error:

ERROR: wram.asm(536):
    Constant mustn't be negative: -528
make: *** [Makefile:42: wram.o] Error 5

Does anyone know what I'm doing wrong?

Offline

#2 2018-07-21 00:32:03

rbroab
Member
Registered: 2017-06-13
Post 75/86

Re: Can't compile Gen. II graphics hack for Yellow

The compiler is telling you there's an error and it's also telling you that error sort of originates from. In this instance, there's an error in the file "wram.asm" on line 536.

This doesn't mean the error is always on the line mentioned in the parentheses. But errors will always be in relation to the mentioned line. Looking at the error you've been given, I'd say the compiler doesn't like the value -528. Is there a reason it needs to be -528 and not 528?

Offline

#3 2018-07-21 00:58:15

_Q_
Member
Registered: 2018-07-20
Post 2/10

Re: Can't compile Gen. II graphics hack for Yellow

rbroab wrote:

Looking at the error you've been given, I'd say the compiler doesn't like the value -528. Is there a reason it needs to be -528 and not 528?

It's not my code, so I'm not really sure. The file in question is here: https://github.com/dannye/pokered-gen-I … r/wram.asm

I actually can't find the value -528 anywhere in the file.

Offline

#4 2018-07-21 18:33:11

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,099/1,119

Re: Can't compile Gen. II graphics hack for Yellow

I bet you're using an rgbds version 0.3.x
Until I update the code, you need to use rgbds v0.2.5


Explanation:

This is the problem code:

wPrinterSerialReceived:: ; c6f0
    ds 1
wPrinterStatusReceived:: ; c6f1
; bit 7: set if error 1 (battery low)
; bit 6: set if error 4 (too hot or cold)
; bit 5: set if error 3 (paper jammed or empty)
; if this and the previous byte are both $ff: error 2 (connection error)
    ds 1

wc6f2:: ; c6f2
    ds 1
wc6f3:: ; c6f3
    ds 13
wLYOverrides:: ; c700
    ds $100
wLYOverridesEnd::
wLYOverridesBuffer:: ; c800
    ds $100
wLYOverridesBufferEnd:: ; c900
    ds wPrinterSerialReceived - @

wPrinterSendDataSource1:: ; c6f0
; two 20-tile buffers
    ds $140
wPrinterSendDataSource2::
    ds $140

The problem is that wPrinterSerialReceived and wPrinterSendDataSource1 both need to be at address 0xc6f0 (that ram address is reused for multiple purposes depending on the context).
In fact, the whole region 0xc6f0 to 0xc900 is used for different purposes depending on the context.

What could have been done is that all these labels could have been interwoven so that each label lands at the correct address. But that would look ugly and confusing (since most of these labels represent data structures that are more than one byte).

So instead, a bunch of labels are defined so that no data structure is "split" with an unrelated label appearing in the middle. Then, "back up" to 0xc6f0 again and define the rest of the labels.
This is done with the line "ds wPrinterSerialReceived - @".
The "@" means "the current address" (0xc900 at this point).

So "wPrinterSerialReceived - @" becomes "0xc6f0 - 0xc900" which becomes "-528".

This became disallowed in rgbds v0.3.x because a better alternative was introduced. "UNIONS" basically allow this exact same thing to be accomplished, but without hackish uses of defining negative space.
I haven't updated the code yet to use the newer unions, so you have to use the last version of the assembler that allowed negative spaces.

Offline

#5 2018-07-25 22:11:57

_Q_
Member
Registered: 2018-07-20
Post 3/10

Re: Can't compile Gen. II graphics hack for Yellow

@Danny-E 33: Thanks! That worked.

Offline

Board footer

Powered by FluxBB