Code Monkey home page Code Monkey logo

Comments (7)

binji avatar binji commented on May 23, 2024

This is really interesting! I looked at the code, and it seems like it should do the right thing... this seems like it would be a pretty common operation, so I found a game that does it and traced it on my system:

A:80 F:Z-HC BC:A016 DE:0080 HL:c286 SP:fff6 PC:4bee (cy: 8632816) ppu:+0 |[01]0x4bee: 87        add a,a        
A:00 F:Z--C BC:A016 DE:0080 HL:c286 SP:fff6 PC:4bef (cy: 8632820) ppu:+0 |[01]0x4bef: 32        ld [hl-],a     

It produces the expected result, Z--C. So I'm not sure how you got the wrong result there. What rom did you use to repro this error, and what version of the emulator?

I just pushed v0.1.4, try that and see if it has the same issue (you need to use binjgb-tester-debug now if you want tracing).

from binjgb.

gitendo avatar gitendo commented on May 23, 2024

I've attached the rom in question. It's a simple test using RNC mode 2. Basically just a call to unpack function and dead loop to count cycles. I've just tried v0.1.4 but it also never returns from call - reason seems to be the same. Thanks for looking into this!

from binjgb.

binji avatar binji commented on May 23, 2024

The cycles and instruction addresses don't line up for me, but I still get Z--C in the equivalent case:

A:80 F:---- BC:0000 DE:c219 HL:0259 SP:fffc PC:01e8 (cy: 1432) ppu:+2 |[00]0x01e8: 18 09     jr +9          
A:80 F:---- BC:0000 DE:c219 HL:0259 SP:fffc PC:01f3 (cy: 1444) ppu:+2 |[00]0x01f3: 87        add a,a        
A:00 F:Z--C BC:0000 DE:c219 HL:0259 SP:fffc PC:01f4 (cy: 1448) ppu:+2 |[00]0x01f4: 38 08     jr c,+8        
A:00 F:Z--C BC:0000 DE:c219 HL:0259 SP:fffc PC:01fe (cy: 1460) ppu:+3 |[00]0x01fe: 28 ea     jr z,-22       
A:00 F:Z--C BC:0000 DE:c219 HL:0259 SP:fffc PC:01ea (cy: 1472) ppu:+3 |[00]0x01ea: 2a        ld a,[hl+]     

I also see the loop end after ~300k cycles:

A:02 F:ZN-C BC:0000 DE:d1a0 HL:0e9b SP:fffc PC:023b (cy: 303240) ppu:+0 |[00]0x023b: 87        add a,a        
A:04 F:---- BC:0000 DE:d1a0 HL:0e9b SP:fffc PC:023c (cy: 303244) ppu:+2 |[00]0x023c: 20 02     jr nz,+2       
A:04 F:---- BC:0000 DE:d1a0 HL:0e9b SP:fffc PC:0240 (cy: 303256) ppu:+2 |[00]0x0240: 38 b1     jr c,-79       
A:04 F:---- BC:0000 DE:d1a0 HL:0e9b SP:fffc PC:0242 (cy: 303264) ppu:+2 |[00]0x0242: c9        ret            
A:04 F:---- BC:0000 DE:d1a0 HL:0e9b SP:fffe PC:015a (cy: 303280) ppu:+2 |[00]0x015a: 76        halt 

Now I'm wondering if this is specific to the win64 version... I'll check.

from binjgb.

gitendo avatar gitendo commented on May 23, 2024

Hm, that's odd. I get exactly the same results from 32 and 64 bit versions. It doesn't set the flag and is stuck in infinite loop repeating the same part of code. I've some thin client here which has Win XP & 32 bit cpu, so I'll try to see if it makes any difference.

Edit:
Looks like TC is too old: binjgb-tester.exe is not a valid Win32 application but linux version works flawlessly, too bad I haven't tried it earlier. :) Still, it's quite strange why Windows ver. acts that way.

from binjgb.

binji avatar binji commented on May 23, 2024

Yep, just found the same thing as you in the windows version:

A:80 F:---- BC:0000 DE:c219 HL:0259 SP:fffc PC:01e8 (cy: 1432) ppu:+2 |[00]0x01e8: 18 09     jr +9          
A:80 F:---- BC:0000 DE:c219 HL:0259 SP:fffc PC:01f3 (cy: 1444) ppu:+2 |[00]0x01f3: 87        add a,a        
A:00 F:---C BC:0000 DE:c219 HL:0259 SP:fffc PC:01f4 (cy: 1448) ppu:+2 |[00]0x01f4: 38 08     jr c,+8        
A:00 F:---C BC:0000 DE:c219 HL:0259 SP:fffc PC:01fe (cy: 1460) ppu:+3 |[00]0x01fe: 28 ea     jr z,-22       
A:00 F:---C BC:0000 DE:c219 HL:0259 SP:fffc PC:0200 (cy: 1468) ppu:+3 |[00]0x0200: 01 02 00  ld bc,2        

I'll keep looking.

from binjgb.

binji avatar binji commented on May 23, 2024

I tried building it myself with VS 2019, and it worked. Maybe this is a VS2015 bug? I ran the same test with ubsan on linux and didn't find any issues.

from binjgb.

gitendo avatar gitendo commented on May 23, 2024

Nice! Meanwhile I've finished those tests with linux build but I'll be using it in near future for sure, so working windows version is more than welcomed. :) Thanks!

from binjgb.

Related Issues (20)

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.