It is currently Sun Sep 23, 2018 6:25 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3
Author Message
PostPosted: Mon Mar 19, 2018 8:30 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20567
Location: NE Indiana, USA (NTSC)
That gets complicated when each actor ends up with dozens of different Uses flags, one for each possible line that could be in or not in a particular actor's script, that need to get copied from the actor's prototype. It gets doubly complicated when a line in the Grand Unified Script needs to turn a bunch of Uses flags on and off when an actor goes in or out of a particular state.

Today I decided to look at how commercial games solve the SOA vs. AOS dilemma. But I discovered that very few Game Boy games listed on Data Crystal actually have their RAM map substantially filled in. The first one I found was that of Wario Land, which has an 8-entry actor table at $A200, where the actors occupy $A200-$A213, $A220-$A233, $A240-$A253, ..., $A2E0-$A2F3. I guess this validates the array of 32-byte-aligned actor structures.


Top
 Profile  
 
PostPosted: Mon Mar 19, 2018 9:19 pm 
Offline

Joined: Tue Feb 07, 2017 2:03 am
Posts: 579
I've recently started tumbling down the Z80 rabbit hole.. Only I have a full Z80 at my disposal and 6502 that I can jump back to when the going gets too hot for the Z80 ;)

I'm starting to think that the dispatch is the way to solve the issue.
We are use to doing

Get thing,x
and state
bne _next
lda otherData,x
adc moreData,x
sta otherData,x
and state2
bne _next2
...thing2

while for Z80 it might be better to use the "use bits" as a dispatch.
ld use
<<2
add Base Pointer
call

this way you put a function that knows what the use cases are and can handle the bits without having to look them up. Saving the need to index into multiple tables.

Not done too much experimentation yet, as I'm still trying to find an assembler that isn't circa 1982. Or one that is 1987 spec but isn't trapped on a machine that is slow...


Top
 Profile  
 
PostPosted: Fri May 11, 2018 11:52 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20567
Location: NE Indiana, USA (NTSC)
My bad luck continues. I searched Google for 8080 record field access and 8080 struct field access, hoping to stumble on some idiom that has become common practice, but most results were some website hosted on port 8080, not Intel 8080. I tried 8080 assembly struct field access, and Google tried to second guess me with "Missing: 8080"


Top
 Profile  
 
PostPosted: Fri May 11, 2018 12:43 pm 
Offline

Joined: Sun Mar 27, 2011 10:49 am
Posts: 265
Location: Seattle
If you put a search term in quotes Google won't show you results without it.

You might try looking at the output of 8080 or GBZ80 C compilers when interacting with structs to see how they handle the problem.


Top
 Profile  
 
PostPosted: Fri May 11, 2018 5:46 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20567
Location: NE Indiana, USA (NTSC)
adam_smasher wrote:
You might try looking at the output of 8080 or GBZ80 C compilers

In other words, the godbolt solution. I'd've tried that if SDCC were any good. See "To C or not to C?" by ISSOtm.
ISSOtm wrote:
[GBDK is] built on an ancient build of SDCC, which is known to generate poor (bloated) and often straight up wrong code.

What C compilers targeting 8080 are any good? Any luck with, say, BDS C?


Top
 Profile  
 
PostPosted: Fri May 11, 2018 7:14 pm 
Offline

Joined: Sun Mar 27, 2011 10:49 am
Posts: 265
Location: Seattle
It might be worth giving SDCC a shot anyway - it's still under active development, and the aforementioned "ancient build of SDCC, which is known to generate poor (bloated) and often straight up wrong code" that GBDK is based on is 17 years old.


Top
 Profile  
 
PostPosted: Thu May 24, 2018 8:55 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20567
Location: NE Indiana, USA (NTSC)
In GBDev Discord, ISSOtm announced an RGBDS macro pack to define structs and is trying to figure out how to best distribute it. Alongside this came some practical idioms for struct field access.
Code:
  ; Prep: 3 mcycles each
  ld de,self
  ld bc,other_actor

  ; Random field load/store: 7 mcycles, BC preserved
  ld hl,offsetof(Actor, xsub)  ; 3
  add hl,de                    ; 2
  ld a,[hl]                    ; 2
  ; Compare 6502: 5 cycles (minus 1 for load not crossing page)
  lda actor_xsub,x             ; 4

  ; Random field arithmetic: 8 mcycles, BC preserved
  ld hl,offsetof(Actor, xsub)  ; 3
  add hl,de                    ; 2
  ld l,[hl]                    ; 2
  add a,l                      ; 1
  ; Compare 6502: 4 cycles (plus 1 for crossing page)
  add actor_xsub,x             ; 4

  ; Store constant in field: 8 mcycles, ABC preserved
  ld hl,offsetof(Actor, frame)  ; 3
  add hl,de                     ; 2
  ld [hl],FRAME_JUMP            ; 3
  ; Compare 6502: 7 cycles and A is clobbered
  lda #FRAME_JUMP               ; 2
  sta actor_xsub,x              ; 5

Roughly: LR35902 is faster for sequential access, and 6502 is faster for random access. Try counting aaaa,X vs. (dd),Y accesses in your NES program to estimate what parts might become slower or faster respectively.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 37 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 1 guest


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