Author Topic: [TIGCC] 68k C  (Read 25150 times)

0 Members and 1 Guest are viewing this topic.

saubue

  • Guest
[TIGCC] 68k C
« Reply #45 on: January 22, 2006, 10:56:00 pm »
QuoteBegin-Liazon+20 January 2006, 18:45-->
QUOTE (Liazon @ 20 January 2006, 18:45)
How do you know when you need to optimize your C code?  

 Hm.. I try to comment my code as clear as possible, so when I read through my code and find pages of uncommented functions, I think it's time to read through it again and to structure and comment it.

It's hard to define what BAD code is; I would say it's uncommented, unstructured (no tab indents, no blank lines). Avoiding memory-management with malloc() is also bad.
I like (so I think it's good code) making typedefs and structs, so that variables tell you what they do.  

arti

  • Guest
[TIGCC] 68k C
« Reply #46 on: January 23, 2006, 01:44:00 am »
My C code!

Liazon

  • Guest
[TIGCC] 68k C
« Reply #47 on: January 23, 2006, 07:12:00 am »
QuoteBegin-saubue+23 January 2006, 4:56-->
QUOTE (saubue @ 23 January 2006, 4:56)
It's hard to define what BAD code is; I would say it's uncommented, unstructured (no tab indents, no blank lines). Avoiding memory-management with malloc() is also bad.
I like (so I think it's good code) making typedefs and structs, so that variables tell you what they do.  

Wow I don't even know what those are.  But malloc() I still quite don't get.  What is it really? and why do you need it?

Based on my previous ASM experience, all I know is that every label you make, ever command you type, all takes up bytes in memory.  The label is a manifest constant of the actual location/address of that data.  It just makes it easier to reference the part of the program.  Otherwise you can define areas of saferam to hold data until the program is done executing.  Does this have anything to do with malloc()?

It's quite obvious that I have a lot more reading to go through.  Perhaps I should take a break from z80 for awhile and put more focus on understanding C.  I think this is a good idea considering how I need to figure out how to access an external data file, pass on sprite data to a sprite data buffer, and lots of other things for DEM.  After pondering the pseudo-code for DEM's battle engine, I'm starting to wonder how I can optimize it, considering so far it seems really huge in my head, and it has lots and lots of animations.

MathStuf

  • Guest
[TIGCC] 68k C
« Reply #48 on: January 23, 2006, 12:09:00 pm »
Malloc is way to reserve RAM for a variable instead of reserving it inside the program itself.

Labels are, in general, bad. There is always a way around using labels.

If you need any help with file manipulation, just catch me on IRC and I can walk you through it there on what you need.

Liazon

  • Guest
[TIGCC] 68k C
« Reply #49 on: January 23, 2006, 12:21:00 pm »
What channel?

oh so malloc() is the z80 equivalent of #define variable = saferam+1

edit: oh nvm omnimaga channel.

Liazon

  • Guest
[TIGCC] 68k C
« Reply #50 on: January 26, 2006, 10:01:00 am »
c1-->
CODE
ec1void GraySprite16_MASK(short x,short y,short h,unsigned short* sprite1,unsigned short* sprite2,unsigned short* mask1,unsigned short* mask2,void* dest1,void* dest2) __attribute__((__stkparm__));c2
ec2

c1
-->
CODE
ec1void GraySprite16_MASK_R(register short x asm("%d0"),register short y asm("%d1"),register short h asm("%d2"),unsigned short *sprt0,unsigned short *sprt1,unsigned short *mask0,unsigned short *mask1,register void *dest0 asm("%a0"),register void *dest1 asm("%a1")) __attribute__((__stkparm__));c2
ec2

What's the difference?  the second one just looks to me like the first one plus more complicated inputs?

btw, is MASK faster or BLIT?

edit: the reason why I can't test this out myself at the moment is that I forgot I don't have an emulator anymore, and I can't seem to get TiEmu to work.  I installed th GTK and then TiEmu, but when I ran TiEmu, it came out with a message saying that some dlls were missing.

Offline Ranman

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1354
  • Rating: +83/-0
    • View Profile
[TIGCC] 68k C
« Reply #51 on: January 26, 2006, 10:06:00 am »
QuoteBegin-Liazon+26 January 2006, 16:01-->
QUOTE (Liazon @ 26 January 2006, 16:01)
What's the difference?  the second one just looks to me like the first one plus more complicated inputs?

btw, is MASK faster or BLIT?  

 The "_R" functions are a tad faster. The arguments get passed directly into registers. The others are put on the stack then copied into registers.

Not sure about BLIT... I've never used it.
Ranman
Bringing Randy Glover's Jumpman to the TI-89 calculator. Download available at Ticalc.

Liazon

  • Guest
[TIGCC] 68k C
« Reply #52 on: January 26, 2006, 10:07:00 am »
Can the _R ones be used interchangeably? or can I only input values of the "register short type?"  hehe, must be the register part that is confusing me.

Offline Ranman

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1354
  • Rating: +83/-0
    • View Profile
[TIGCC] 68k C
« Reply #53 on: January 26, 2006, 12:27:00 pm »
QuoteBegin-Liazon+26 January 2006, 16:07-->
QUOTE (Liazon @ 26 January 2006, 16:07)
Can the _R ones be used interchangeably? or can I only input values of the "register short type?"  hehe, must be the register part that is confusing me.  

 Yes, they can be used interchangeably.

Don't worry too much about the 'register' keyword. It is basically a compiler implementation modifier that says "if a register is available, then use it". If a register is not available, then the compiler will choose what to do. Putting values directly into registers is just a bit faster. In your Extgraph API call above, it expressly states to put parameters you pass into registers D0, D1, and D2.  
Ranman
Bringing Randy Glover's Jumpman to the TI-89 calculator. Download available at Ticalc.

Liazon

  • Guest
[TIGCC] 68k C
« Reply #54 on: February 04, 2006, 03:17:00 pm »
What are all the data compression options for 68k?  Like, how do you fit so much stuff (sprites, maps, etc.) into a game?

In fact, I don't even know how you do that on an 83+.  I don't even understand what a group file is!

edit: oh ya, what's ppg?

edit (again): oh ya, please forgive my ignorance :bow:worship.gif:bow:worship.gif

saubue

  • Guest
[TIGCC] 68k C
« Reply #55 on: February 04, 2006, 06:42:00 pm »
Normally, you can all store your data in your program. If the program gets too large (> 64kB), there are different ways to make it still possible to make larger:

- You can ExePack your program after it has been compiled by TIGCC. The compression ratio is very good. TIGCC then creates a launcher (an ASM Program that is about 1kB small) and a .ppg-file that contains the compressed program.

- You can store data (like sprites, maps, strings etc.) in external files. These can be created in multiple ways, although it's common to create them with ttarchive (a program that is part of the TIGCC Tools Suite). ttarchive also offers the possibility to compress the data.
This way, you can load the data from the files just when they are needed.

- You can make a DLL-file that contains executable code (e.g. the FAT-Engine. CalcRogue uses this, too).

Hm... that's all I can think of right now (sun begins to rise, so I think I should go to sleep ;)wink.gif )

Liazon

  • Guest
[TIGCC] 68k C
« Reply #56 on: February 05, 2006, 05:50:00 am »
Why can't I find the TIGCC Tools suite on the TICT website?

Thanks saubue.  Is the dll file the same as creating a .a file?  I'm guessing I need to read the readmes to learn how to access data in ttarchives and ppg files and dll files.

Offline Ranman

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1354
  • Rating: +83/-0
    • View Profile
[TIGCC] 68k C
« Reply #57 on: February 05, 2006, 07:07:00 am »
QuoteBegin-Liazon+5 February 2006, 11:5-->
QUOTE (Liazon @ 5 February 2006, 11:50)
Why can't I find the TIGCC Tools suite on the TICT website?

Here are some good links for you:

http://tict.ticalc.org/
http://www.ticalc.org/archives/files/fileinfo/161/16198.html
http://tigcc.ticalc.org/

QuoteBegin-Liazon+5 February 2006, 11:50
-->
QUOTE (Liazon @ 5 February 2006, 11:50)
Thanks saubue.
Ranman
Bringing Randy Glover's Jumpman to the TI-89 calculator. Download available at Ticalc.

Liazon

  • Guest
[TIGCC] 68k C
« Reply #58 on: February 05, 2006, 07:14:00 am »
I'm sorry, forgive my ignorance.  :bow:worship.gif

so TIGCC creates the dll?

argh!!! I'll figure this out eventually, somehow, on my own, I duno what I'm doing, wutever

Offline Ranman

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1354
  • Rating: +83/-0
    • View Profile
[TIGCC] 68k C
« Reply #59 on: February 05, 2006, 07:27:00 am »
QuoteBegin-Liazon+5 February 2006, 13:14-->
QUOTE (Liazon @ 5 February 2006, 13:14)
I'm sorry, forgive my ignorance.  :bow:worship.gif

so TIGCC creates the dll?  

 Don't worry about it...

TIGCC can create '.a' and '.dll' files. I haven't messed with DLL files much so I wont be much help. But, you only need them if you think your main program is going to be larger than 64Kb. If it is not... don't worry about a DLL.

Ultima V may need a DLL file. So, I may have to look into this for myself. If you still want more details, I'll be glad to check this out and provide more in-depth details.
Ranman
Bringing Randy Glover's Jumpman to the TI-89 calculator. Download available at Ticalc.