![]() ![]() |
Jun 6 2008, 02:09 PM
Post
#16
|
|
|
Jaguar DKG Stick ![]() ![]() ![]() Group: JSII Honorary VIP Posts: 231 Joined: 7-January 08 From: London Member No.: 2,682 |
Just start with small routines ( although Gorf quite correctly points out that gpu code is the most efficient way, it can be difficult to debug
You can call routines from the 68k to do useful things, like this sprite list builder... CODE ;Object list builder, ;Takes list of sprites and produces Object list ready for display objptr equr r0 sprites equr r1 numsprites equr r2 sortlist equr r3 temp1 equr r4 temp2 equr r5 numdisplay equr r6 jadd equr r7 maxpoint equr r8 search equr r9 count equr r10 ptr equr r11 point equr r12 swap equr r13 maxptr equr r16 x equr r17 y equr r18 scale equr r19 size equr r20 offsets equr r21 flags equr r22 dataptr equr r23 lw1 equr r24 lw2 equr r25 highptr equr r26 graphic equr r27 gpulister: nop gpu_object: movei #99999,objptr ;Fetch object list ptr nop gpu_sprites: movei #99999,sprites ;Fetch sprite list ptr nop gpu_spritecount: movei #99999,numsprites;Total number of sprites to process ;First of all count sprites and prepare initial drawlist... movei #sortptrs,sortlist;GPU sorted list cmpq #0,numsprites ;Are there any sprites defined... movei #ssize,temp2 ;Size of sprite structure jr eq,.nobuild ;First build an initial list of displayed sprites... ;Build initial list MK2 moveq #0,numdisplay .buildloop: loadw (sprites),temp1 ;stype flags addqt #4,sprites cmpq #0,temp1 ;Is sprite active load (sprites),temp1 ;Fetch Z and Y subqt #4,sprites store sprites,(sortlist) jr eq,.nobuild subq #1,numsprites ;Next sprite addqt #4,sortlist addqt #1,numdisplay ;Increase number of sprites to display store temp1,(sortlist) addqt #4,sortlist .nobuild: nop jr ne,.buildloop add temp2,sprites ;Point to next sprite ;Do the same thing with the options list.... movei #optionslist,sprites moveq #num_options,numsprites .buildopts: loadw (sprites),temp1 ;stype flags addqt #4,sprites cmpq #0,temp1 ;Is sprite active load (sprites),temp1 ;Fetch Z and Y subqt #4,sprites store sprites,(sortlist) jr eq,.no_opt subq #1,numsprites ;Next sprite addqt #4,sortlist addqt #1,numdisplay ;Increase number of sprites to display store temp1,(sortlist) addqt #4,sortlist .no_opt: nop jr ne,.buildopts add temp2,sprites ;Point to next sprite ;Now sort the displayed sprites into Z/Y order cmpq #2,numdisplay ;Less than 2 sprites visible? move numdisplay,numsprites;Number to sort movei #.sortloop,jadd jr pl,.sortloop subqt #1,numsprites movei #nosortneeded,jadd jump t,(jadd) nop .sortloop: moveq #0,maxpoint movei #sortptrs,search;GPU sorted list move numsprites,count;To sort this time round .onepoint: load (search),ptr addqt #4,search load (search),point subqt #4,search cmp maxpoint,point ;Is this bigger nop jr mi,.smaller nop move search,swap ;New front move ptr,maxptr move point,maxpoint .smaller: subq #1,count addqt #8,search ;Next point jr ne,.onepoint nop ;Swap last point and max point.... subqt #8,search ;Last point store ptr,(swap) addqt #4,swap store maxptr,(search) addqt #4,search store point,(swap) subq #1,numsprites store maxpoint,(search) ;Now sort for next foremost... jump ne,(jadd) ;Loop back to sort routine nop nosortneeded: ;At this stage all sprites should be sorted (hopefully) ;Now start to prepare the object list.... cmpq #0,numdisplay ;Are there any sprites... movei #sortptrs,ptr movei #G_HIDATA,highptr movei #makeobject,jadd jr ne,makeobject nop movei #end_spritebuild,jadd jump t,(jadd) nop makeobject: load (ptr),sprites ;Fetch sprite address addqt #4,ptr load (sprites),x ;Fetch type and X co-ord addqt #8,sprites load (ptr),y ;Fetch Z and Y co-ord addqt #4,ptr load (sprites),scale ;Fetch sprite scaling value addqt #4,sprites load (sprites),graphic;Fetch sprite graphic... load (graphic),size ;Fetch sprite width and height addqt #4,graphic load (graphic),offsets;Fetch origin offsets addqt #4,graphic load (graphic),flags ;Fetch sprite flags and other info addqt #4,graphic load (graphic),dataptr;Fetch address of sprite graphics ;All info available... now prepare sprite data addqt #32,objptr move objptr,lw1 subqt #32,objptr move lw1,lw2 shrq #11,lw1 ;MS part of link shlq #21,lw2 ;LS part of link shlq #8,dataptr ;Pre shift data pointer or dataptr,lw1 ;lw1 ready move offsets,temp1 shlq #16,temp1 ;Y offset only shlq #16,y ;Lose z co-ord add temp1,y ;Find corner co-ord move size,temp1 ;Height is low word shrq #12,y shlq #16,temp1 ;height only or y,lw2 ;Y field inserted shrq #2,temp1 store lw1,(highptr) ;Store high long word or temp1,lw2 ;Height field inserted storep lw2,(objptr) ;and transfer phrase to ram addqt #8,objptr ;Now second phrase... shrq #16,offsets ;X offset only add x,offsets shlq #20,offsets shrq #20,offsets ;X field move flags,lw2 shlq #16,lw2 ;Extract Depth/Pitch and DWIDTH from flags shrq #4,lw2 or offsets,lw2 ;add X position field move flags,lw1 ;Extract IWIDTH (ms part) and misc flags shrq #10,lw1 shrq #6,flags ;Extract IWIDTH (ls part) shlq #28,flags or flags,lw2 ;Completed second phrase store lw1,(highptr) ;Store high long word storep lw2,(objptr) ;and transfer phrase to ram addqt #8,objptr ;Third phrase contains scaling info only... move scale,lw2 shrq #16,scale ;X scale factor shlq #16,lw2 ;Y scale on own moveq #0,lw1 shrq #8,lw2 ;Y scale factor store lw1,(highptr) or scale,lw2 ;Complete scaleing value storep lw2,(objptr) addqt #16,objptr ;Point to next sprite object.. ;Any more sprites to display... subq #1,numdisplay jump ne,(jadd) end_spritebuild: ;Finally place a stop object moveq #4,lw2 moveq #1,temp1 storep lw2,(objptr) ;Stop object ;Finished...Terminate GPU program.. movei #gpu_semaphore,ptr store temp1,(ptr) moveq #0,temp1 movei #G_CTRL,ptr store temp1,(ptr) nop nop long gpu_semaphore: dc.l 0 phrase ;GPU sort list goes here sortptrs: ;End of GPU code..... .68000 |
|
|
|
Jun 6 2008, 03:02 PM
Post
#17
|
|
|
Jaguar Motorola Test Deck ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: JSII Super Moderator Posts: 7,213 Joined: 19-May 04 From: Beaverton Oregon Member No.: 12 |
See that's the problem. I have only the vaguest idea what that means. There's a lot of us that want to learn assembler but we need to learn it in smaller chunks.
This post has been edited by JagChris: Jun 6 2008, 03:02 PM |
|
|
|
Jun 6 2008, 05:52 PM
Post
#18
|
|
|
Jaguar Alpine Board ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: JSII Platinum Posts: 1,770 Joined: 19-May 04 From: Lompoc, CA Member No.: 17 |
QUOTE(Gorf @ Jun 6 2008, 01:41 AM) [snapback]248119[/snapback] What everyone seems to forget it the pipelined nature of the RISC's as opposed to all those books that talk about CISC. You will want to know what interleaving is. You probably wont learn that reading from non-RISC books. Look at a Motorola DSP book instead. Those are RISC and much more like the J-RISC's(as motorola was part of the J-RISC..it was based off the moto DSP's.) The 6502 is CISC. CISC uses what is called micro code. The 6502 interprets instructions into internal microcode(the actual physical logic that performs the operations.) The J-RISC set of instructions IS the microcode. There is also the lack of registers available on the 6502. Then there is the fact that there is no local or cache mem on the 6502(at least not originally). Most RISC's have at least a k or two of local/cache memory. Most RISC's usually have a generous bank or two of gen purp registers. However the 6502 'behaves' like a RISC having a small instruction set and executing most operations within a cycle or two. This chip with a bunch more registers at a fast clockrate would be awsome. However, there is also the RISC registers and instructions forums. You got questions? We got answers! I stand corrected, or at least clarified, about the 6502. As far as the J-RISC, a good portion if not all of the K series Jaguar's have Toshiba manufacturered chips. Motorola came in later as an alternate source (M serial # series Jaguar's) and appeared to become a preferred (as far as I can tell) company to work with. I think Toshiba became a pain-in-ass for Atari to work with. You can tell quite easily when you look at the two Jaguar chipset chips inside the Jag as to who made them. Glenn |
|
|
|
Jun 6 2008, 06:02 PM
Post
#19
|
|
|
Jaguar Alpine Board ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: JSII Platinum Posts: 1,770 Joined: 19-May 04 From: Lompoc, CA Member No.: 17 |
So Gorf, is your knowledge about programming all self-taught or do you have some formal education? Just curious. Most of mine has been learning on my own. It wasn't until recent times that I've taken some courses as part of my engineering degree pursuit.
My first official college programming classes have been (course #'s with the colleges I attended): DE295 - electronics tech course where we used 8051 style microcontroller EE312 - a digital electronics course for EE's where a Motorola 68HC11 microcontroller was taught (my 6502 cookbook's came in handy for this!) COM SC 175 - my first high level course - C++ (before that mostly basic and a extremely tiny bit of Forth and Python) I also enjoy trying to do assembler myself. I'm just more comfortable with it. But it was nice to get some background in C++ only to have a way to attempt to write utility programs for myself on a PC. Just have no desire for PC assembly. Glenn |
|
|
|
Jun 6 2008, 10:46 PM
Post
#20
|
|
![]() Harmless Lion ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: JSII Super Moderator Posts: 2,704 Joined: 17-August 05 From: BUR Member No.: 256 |
I would not recommend that the Jaguar RISC be anyone's first assembly. In fact I would not recommend the Jaguar be anyone's first assembly platform. You can do it, but it's going to be more difficult.
I would pick a processor that has a good debugger -- either an embedded machine like an Atmel, or if you don't want the hardware investment, even an emulator for a simple machine like the Apple 2 with a 6502. You start with a simple processor, you learn the basics, and with the debugger, you can immediately see the result of each instruction, how it responds and manipulates the registers and interacts with the flags. Programming the Jaguar is not easy - not even by homebrew console standards. Yes, there is work being done to make that a little easier but I recommend getting the concepts down pat first. When you can confidentally answer questions like, "What is a register and when is it used?", "What are the status flags?", and "How does the CPU perform a comparison?", that's a good start. |
|
|
|
Jun 7 2008, 02:30 AM
Post
#21
|
|
|
Jaguar DKG Stick ![]() ![]() ![]() Group: JSII Honorary VIP Posts: 231 Joined: 7-January 08 From: London Member No.: 2,682 |
Stella ( the VCS emulator ) is pretty good, as you run 6502 code on a very simple system, and there's a quite nice built in debugger.
If you learn 6502 then you can pick up most things. The only 'new' concept in the gpu/dsp over older processors like the 6502/68k is the concept of pipelining, but that's not really too complex when you think about it. |
|
|
|
Jun 7 2008, 10:07 PM
Post
#22
|
|
|
Jaguar Motorola Test Deck ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: JSII Super Moderator Posts: 7,213 Joined: 19-May 04 From: Beaverton Oregon Member No.: 12 |
i guess I can try learning 68k assembly then. I had an emulator/simulator for assembly on my other system. I can download it again and start there I guess.
|
|
|
|
Jun 8 2008, 01:25 PM
Post
#23
|
|
|
Jaguar DKG Stick ![]() ![]() ![]() Group: JSII Honorary VIP Posts: 231 Joined: 7-January 08 From: London Member No.: 2,682 |
I dont think the VCS is that complex - as a tutorial it's a lot 'simpler' in the kind of things you do on it. Atari 8 bit maybe - however I found the debuggers not that good ( I used MAC65 for coding ) compared to the built in emulator in Stella.
Z80 has some similar problems to x86 in some ways - so if someone wanted to learn asm I'd say just learn PC. Maybe the 68k is the best thing to start on - or the MIPs processor ( it used to be easy to run PS1 stuff using Caetla.. but most of the sites have gone idle ) as there are loads of online docs ( or I'd recommend visiting a library, as I expect a lot of library books to be based on 68k or MIPs ) You could look at Knuth's page - he teaches algorithms on his own architecture. |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 25th May 2013 - 11:28 AM |