30 May 2002, 14:34 | #1 |
Long time member
Join Date: Jul 2001
Location: UK
Posts: 754
|
I need help in C programming please!!
Ok.. Ive got 3 files....
registers.h typedef struct REG { u8 A,F; // Accumulator / Flag u8 B,C,D,E,H,L; // General purpose 8 bit registers int AF, BC, DE, HL; // 16 bit registers. int PC; // Program Counter int SP; // Stack Pointer. } REG; main.c #include registers.h REG registers; REG* regPtr; can use regPtr fine in here.... ie regPtr->PC = 0x100; etc.. general.c How can I get access to the register structure in this file? I want to be able to pass the regPtr into a function in this file and use it the same way as above.. ie: regPtr->PC = 0x100; etc.. Ive tried using the extern keyword and currently my code looks like... void disp_current_instr(u8* mem) { extern registers; regPtr = ®isters; dispMessage(0, 0, word_to_str(mem[regPtr->PC]), " "); but it doesnt work... Hope someone can understand what Im going on about.. |
30 May 2002, 15:00 | #2 |
Registered User
Join Date: Jul 2001
Location: .
Age: 44
Posts: 246
|
Try this..
// *** registers.h ***
typedef unsigned char u8; typedef struct REG { u8 A,F; // Accumulator / Flag u8 B,C,D,E,H,L; // General purpose 8 bit registers int AF, BC, DE, HL; // 16 bit registers. int PC; // Program Counter int SP; // Stack Pointer. } REG; extern REG registers; extern REG* regPtr; // *** general.c *** #include "registers.h" void disp_current_instr(u8* mem) { regPtr = & registers; dispMessage(0, 0, word_to_str(mem[regPtr->PC]), " "); } // *** main.c *** #include "registers.h" REG registers; REG* regPtr; void main(void) { // stuff disp_current_instr(stuff); // more stuff } |
30 May 2002, 15:22 | #3 |
Long time member
Join Date: Jul 2001
Location: UK
Posts: 754
|
That worked a treat.. Thanks Sane...
|
30 May 2002, 15:34 | #4 |
Long time member
Join Date: Jul 2001
Location: UK
Posts: 754
|
Heres are a couple of screenshots of what Im working on - a Gameboy emulator for the Gameboy Advance in action.
As you can see its still in VERY early stages and only implements one opcode.... JP $aabb (two if you count NOP) but its a start!!! |
30 May 2002, 15:34 | #5 |
Long time member
Join Date: Jul 2001
Location: UK
Posts: 754
|
And after executing next instruction......
|
05 October 2002, 00:34 | #6 |
Registered User
Join Date: Mar 2001
Location: Moorpark, California
Age: 44
Posts: 1,153
|
Nice project mate, hope it works out well.
It's the simple things that are over looked, don't you think? A GB emu for the GBA seems like an obvious path. You'll make a lot of friends if you finish that |
05 October 2002, 12:42 | #7 |
Long time member
Join Date: Jul 2001
Location: UK
Posts: 754
|
Unfortunately I havent done any more to it My work actually found me some 'real' work to do so I never had time..
Will pick it up again at some point. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Programming for the Amiga | burf2000 | Coders. Language | 2 | 16 October 2012 21:13 |
Want to get into programming | ami_junkie | Coders. General | 7 | 13 May 2009 12:55 |
Amiga Programming | stareagle | request.Apps | 1 | 09 June 2007 13:36 |
Amiga programming | magnox | Coders. General | 6 | 28 April 2006 00:33 |
c programming help needed! | jonssonj | Coders. General | 2 | 25 February 2006 20:00 |
|
|