It is currently Mon Dec 18, 2017 4:04 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 42 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject:
PostPosted: Mon Jan 19, 2009 8:13 am 
Offline
User avatar

Joined: Mon Dec 22, 2008 10:45 pm
Posts: 311
Location: Argentina
Wow the thread I started ended up creating a forum! I feel somewhat important.
No, not really.
:D
But as soon as I finish my NES library I'll submerge in the GBdev world! :lol:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2009 12:02 pm 
Offline
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2143
Location: Minneapolis, Minnesota, United States
Petruza wrote:
Wow the thread I started ended up creating a forum! I feel somewhat important.
No, not really.
:D
But as soon as I finish my NES library I'll submerge in the GBdev world! :lol:


Celius wrote:
(From second post in thread)...Perhaps it'd be nice if a GBDev forum was opened up like the SNESDev forum here.


Oh, I think that was all my doing 8) :lol:

Someday I'll move onto GBDev. I just can't dive into it right now, because I have too much going on. I'll port some of the NES games I make to GB/GBC when I finish them.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2009 12:25 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7320
Location: Chexbres, VD, Switzerland
It could be great if we could have a tool that would convert 6502 code to GB-Z80 codes automatically :wink:
Of couse a lot of fixes would have to be done and all I/O routines would have to be fully rewritten (along with any routine where speed matters). But it could still save some work.

_________________
Life is complex: it has both real and imaginary components.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2009 1:24 pm 
Offline
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2143
Location: Minneapolis, Minnesota, United States
I don't know, I don't think I'd like to convert 6502 code automatically. Pretty much any straight conversion proves to make slow code, and I really want to be sure of every single instruction that I execute. Otherwise I feel cheap. And besides, I kind of like how working with the Z80 feels.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2009 1:40 pm 
Offline
User avatar

Joined: Mon Dec 22, 2008 10:45 pm
Posts: 311
Location: Argentina
Celius wrote:
Oh, I think that was all my doing 8) :lol:


Damn. Ok I'll recognize 50% responsibility to you. Not more. :x

Celius wrote:
I'll port some of the NES games I make to GB/GBC when I finish them.


Which are? It would be great to have like a main list with each forum member and his games, available for download or in video demos, so everybody can appreciate the work of the others.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2009 1:55 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
Celius wrote:
I don't know, I don't think I'd like to convert 6502 code automatically. Pretty much any straight conversion proves to make slow code

Because the GB-Z80 has many more registers. 6502 code will tend to push things on the stack or make use of zero-page, while GB-Z80 code will keep things in other registers. A translator will have a hard time doing this, since it can have a hard time knowing whether a zero-page value is just used as a temporary, or later read by the calling routine.
Quote:
And besides, I kind of like how working with the Z80 feels.

Like working with the x86, unpleasant? You get more operations, but there are more obscure limitations, timing differences, and opcoding encoding inconsistencies. On the other hand, the GB-Z80 has lots more things directly supported:
- Register-to-register operations, like A=A AND B
- 16-bit arithmetic, like HL=HL+BC, DE=DE-1
- 16-bit memory indexing using a register pair, and auto-increment/decrementing
- Easy stack-local variables by being able to add signed 8-bit immediate to stack pointer, and load HL with stack pointer + signed 8-bit immediate
- Push/pop any register pair
- Set/reset bit in register/memory byte
- Conditional call and return


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2009 3:08 pm 
Offline
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2143
Location: Minneapolis, Minnesota, United States
Petruza wrote:
Celius wrote:
Oh, I think that was all my doing 8) :lol:


Damn. Ok I'll recognize 50% responsibility to you. Not more. :x


Are you sure? Not even 75%? Haha, just kidding.

Petruza wrote:
Which are? It would be great to have like a main list with each forum member and his games, available for download or in video demos, so everybody can appreciate the work of the others.


I was going to update my site to have information about the games I'm working on. These are far from completion, and I'm more focusing on one in particular, which is a Castlevania spoof. My site doesn't have the information about it right now, because I'm in the middle of rearranging it. I'll try and get it up soon. I'll let you know when it's all updated.

blargg wrote:
Like working with the x86, unpleasant?


What do you mean by that? I've never worked with x86. The only assembly languages I've worked with are 6502, 65816, and GB-Z80. Oh, and when I said Z80 before I meant GB-Z80.

I like how in GB-Z80 you kind of load-and-store in one line. But I suppose they are really more of statements like TAX or TAY when you say something like:

ld a,h

It was really easy to dive right into with this intuitive format.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2009 3:25 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7320
Location: Chexbres, VD, Switzerland
What makes me really complaining about the GB-Z80 is that there is no indexed adressing *at all* and I use it all the time on the 6502 so I'd have a really hard time to port code.

The only way to acess an array is to use indirect adressing and you have only *one* indirect pointer to do that woks. So if you want to do such a smple thing as copy an array to another in reverse order, while it's very easy on the 6502, it would end up a headache on the GB-Z80.

_________________
Life is complex: it has both real and imaginary components.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2009 4:29 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
Maybe I'm missing something, but doesn't this do what you describe?
Code:
    ; Copy 3 bytes from foo to bar, in reverse order
    ld  b,3
    ld  de,foo+3
    ld  hl,bar
-   dec de
    ld  a,(de)
    ld  (hl+),a
    dec b
    jr  nz,-

Are you commenting on indexed addressing like the 6502's LDA table,X? The GB-Z80 equivalent is to either align the table to a 256-byte boundary and set the low byte to X,
Code:
    .align 256 ; or whatever hell wla-dx uses
table:
    ; ...

    ; l is set to index already
    ld  h,table>>8
    ld  a,(hl)

or add X to the address.
Code:
 ; l is set to index already
    ld  h,0
    ld  bc,table
    add hl,bc
    ld  a,(hl)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2009 4:32 pm 
Offline

Joined: Thu Aug 28, 2008 1:17 am
Posts: 591
Quote:
The only way to acess an array is to use indirect adressing and you have only *one* indirect pointer to do that woks. So if you want to do such a smple thing as copy an array to another in reverse order, while it's very easy on the 6502, it would end up a headache on the GB-Z80.



There's:

ld a,(BC)
ldi (HL),a
inc BC

Edit: Blargg beat me to it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 20, 2009 7:21 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7320
Location: Chexbres, VD, Switzerland
Oh I didn't note the (BC) instruction. Well you are right guys it sounds like less an headache I originally tought. Still not as cool as the indexed, but workable. I would probably spend most of the time in my programm to load, store and add stuff to BC and HL.

_________________
Life is complex: it has both real and imaginary components.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 20, 2009 3:31 pm 
Offline

Joined: Thu Aug 28, 2008 1:17 am
Posts: 591
LD A,(n16) //n16= (16-bit addr)
LD A,(r16) //r16= (BC),(DE),(HL)
LD (n16),A //n16= (16-bit addr)
LD (r16),A //r16= (BC),(DE),(HL)

Only LDI and LDD are restricted to HL.

The GBC cribsheet is your friend ;)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 42 posts ]  Go to page Previous  1, 2, 3

All times are UTC - 7 hours


Who is online

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