English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 30 May 2002, 14:34   #1
Big-Byte
Long time member
 
Big-Byte's Avatar
 
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 = &registers;

dispMessage(0, 0, word_to_str(mem[regPtr->PC]), " ");

but it doesnt work...

Hope someone can understand what Im going on about..
Big-Byte is offline  
Old 30 May 2002, 15:00   #2
§ane
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
}
§ane is offline  
Old 30 May 2002, 15:22   #3
Big-Byte
Long time member
 
Big-Byte's Avatar
 
Join Date: Jul 2001
Location: UK
Posts: 754
That worked a treat.. Thanks Sane...
Big-Byte is offline  
Old 30 May 2002, 15:34   #4
Big-Byte
Long time member
 
Big-Byte's Avatar
 
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!!!
Attached Thumbnails
Click image for larger version

Name:	emu_scrn1.png
Views:	416
Size:	1.3 KB
ID:	2651  
Big-Byte is offline  
Old 30 May 2002, 15:34   #5
Big-Byte
Long time member
 
Big-Byte's Avatar
 
Join Date: Jul 2001
Location: UK
Posts: 754
And after executing next instruction......
Attached Thumbnails
Click image for larger version

Name:	emu_scrn2.png
Views:	384
Size:	1.4 KB
ID:	2652  
Big-Byte is offline  
Old 05 October 2002, 00:34   #6
P-J
Registered User
 
P-J's Avatar
 
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
P-J is offline  
Old 05 October 2002, 12:42   #7
Big-Byte
Long time member
 
Big-Byte's Avatar
 
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.
Big-Byte is offline  
 


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 06:01.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.12418 seconds with 16 queries