Coder Social home page Coder Social logo

issotm / gbz80toitems3 Goto Github PK

View Code? Open in Web Editor NEW
10.0 4.0 3.0 110 KB

An online converter translating Game Boy assembly into Pokémon R/B/Y items.

Home Page: https://eldred.fr/gbz80toitems3/

HTML 6.79% CSS 0.49% JavaScript 92.72%
pokemon game-boy gbdev

gbz80toitems3's People

Contributors

drakonua avatar issotm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gbz80toitems3's Issues

jr targets are off by one

The following code:

jr .lab
.lab

produces the item list

Rainbow Badge (hex:18) x255 (hex:FF)

wheras the expected result is

Rainbow Badge x0

This issue also happens with conditional jr instructions.

ldh not working properly

ldh ($ff80),a doesn't compile, instead throwing a memAccess is undefined ! internal error.
In all other cases, ldh doesn't work and throws this same error.

Incorrect db syntax crashes Paper Mario

(Sorry for the title)

db 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
throws an internal error :

Cannot read property 'used' of undefined

Knowing how code is built, this error was thrown at the linker/item-ifier level (this is where the "used" property is used to compute the "duplicate" warning).
However, this syntax is supposed to be invalid ! This code passed the assembler stage, but that alone is abnormal.

The bug must be located in the way the function readByte is implemented. It also made me create issue #9, so read my rant there for details on the bug. Or don't, I won't judge you :)

Missing mnemonics

The following mnemonics are missing in GBz80 to Items

ld [$nnnn], sp ; (Opcode 08)
ld hl, sp+$nn ; (Opcode F8); *
  • The assembler currently translates ld hl, [sp+$nn] to F8, which is wrong, because such an instruction does not exist. But you can keep it for compatibility (like jp [hl] is a synonym of jp hl).

Invalid syntaxes still compile

Syntaxes such as dw $C0 DE compile successfully, even though they should not.

This comes from the assembler, which ignores everything /\w/ - aside from the first of those, since it's the one that separates the instruction from the operands.

Incorrect ld hl, $XXYY implementation ?

ld hl, $D17C
ld a, $E0
ld (hl), a
sub a, $D9
dec hl
ld c, a
inc b
ld (hl), c
ret

This code doesn't compile correctly.

ThunderStone x124
TM09 x62
TM24 x119
TM14 x217
Secret Key x79
Poké Ball x113
TM01 x[any qty]

is expected, but

ThunderStone x62
TM24 x119
TM14 x217
Secret Key x79
Poké Ball x113
TM01 x[any qty]

is generated instead.

Apparently the argument to ld hl, $D17C is skipped entirely.
ld's implementation is a bit of a crying shame, it must be a problem of instruction length - the instruction byte is correct (ThunderStone is output) but the arguments aren't present (2-byte offset)

May not affect ld de, $XXYY and ld bc, $XXYY, but if either suffers from the bug the other should, too.

No db $XX, $YY support (and same for dw)

db's support is limited to only one operand.

This would require separating db's processing function from readByte ; which would actually make code better (readByte only processing a byte and not pushing anything to the byte stream, thus simplfying wrapping around it). however, since this function is used so many times, it would be a huge game of bowling through the code.
To add to the fun, I already have limited time on my hands now. This will have to wait (even though I hate it). In the meantime, I ask you to use separate db instructions. Thanks :)

Of course, all of this applies to dw.

Shortcut for add

Currently, GBz80 to Items does not support the shortcut for add a, X, where X is a register or an address stored in register hl. This does not affect the case where X is a 8 bit integer constant. The mnemonic sub is not affected.

The following instructions

add a
add b
add c
add d
add h
add l
add [hl]

are equivalent to

add a, a
add a, b
add a, c
add a, d
add a, h
add a, l
add a, [hl]

'undefined' is not an object! (line undefined)

It didn't give me a line, so I'll just post the whole code:

Ld c,$00
start:
Call $3ffa
Ldh a,($b2)
Cp $10
jr z,left
Cp $20
Jr z,right
Ldh a,($f8)
Cp $02
jr z,end
Jr start
left:
Dec c
Jr start
right:
inc c
Jr start
end:
ld b,c
ld c,$64
call $3e48
ret

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.