• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
  • entries
    2
  • comments
    2
  • views
    2513

Blitting and Soldering

Sign in to follow this  
Followers 0
Segmented

685 views

Hello all. I promised myself I would post the progress on my game before starting to work on the PUTT contest, so here it goes =) When I came to the question of input for the raspberry pi, my first assumption was that the easiest method would be to use the USB port. However, I reached dead-ends everywhere and eventually decided it was better to wire up my SNES controller to the GPIO port instead, because even if it required I do a bit of soldering it couldn't possibly take longer than writing even a small USB driver.

I ended up using jumper connectors on the pi end, and nails of sufficient diameter on the other.

lu1sRD1.jpg

Major shout out to a guy named Peter Lemon. He has a demo here which is actually exactly what I was trying to accomplish, and most of this was just essentially a replication of his work.

The SNES controller seems to work in two stages. First, you toggle the "latch" high and then low. I presume this updates the controller's internal state. Next you read in the "data" value, and toggle the "clock" high and then low. Repeat this step until all 16 bits of data are read from the controller. Each bit is a button's state on the controller, but its more convenient to append the bits altogether into a single bitfield and use that.

Lastly, I improved upon the blit code from last time. Now it will properly clip when it runs off the screen... that is until it goes completely off, and then it starts drawing random artifacts all over the place.... but nothings perfect =) Since I refactored the code from last time to play nicer with the registers I'd better post everything for it to make sense, instead of as snippets:

.macro var name r .ifdef __\name .unreq \name .endif \name .req \r .set __\name, 1 .endm .macro nop_delay count .rept \count nop .endr .endm .set VS_BASE, 0x2000B208 .set VS_MAG, 12 .set MB_BASE, 0x2000B880 .set MB_STATUS, 0x18 .set MB_WRITE, 0x20 .set GP_BASE, 0x20200000 .set GP_SEL0, 0 .set GP_SEL1, 4 .arm@ ============================================================================== mov sp, #0x8000 var base, r11 var fbi, r10 var fbp, r10 var req, r9 var res, r9 var px, r8 var py, r12@ Initiate output pins. ldr base, =GP_BASE mov req, #0x9 str req, [base, #GP_SEL1]@ Wait til the mailbox is not busy. ldr base, =MB_BASEbusy$: ldr res, [base, #MB_STATUS] tst res, #0x80000000 bne busy$@ Ask for framebuffer info (fbi). ldr fbi, =framebufinfo add req, fbi, #0x40000000 add req, #1 str req, [base, #MB_WRITE]listen$: ldr res, [base, #MB_STATUS] tst res, #0x40000000 bne listen$ ldr res, [base] cmp res, #1 bne listen$@ Wait for v-sync. mov px, #0 mov py, #0 ldr fbp, [fbi, #32]render$: ldr base, =VS_BASE mov req, #0x10000 str req, [base, #VS_MAG] ldr r0, =0x20600000 mov req, #0 str req, [r0]vsync$: ldr res, [base] tst res, #0x10000 beq vsync$@ Poll input. ldr base, =GP_BASE mov req, #0x800 str req, [base, #0x1c] @@ latch on nop_delay 12 str req, [base, #0x28] @@ latch off nop_delay 12 mov r0, #15 mov r1, #0nextbutton$: mov r1, r1, lsl #1 ldr res, [base, #0x34] @@ read bit tst res, #0x10 orreq r1, #1 mov req, #0x400 str req, [base, #0x1c] @@ clock on nop_delay 12 str req, [base, #0x28] @@ clock off nop_delay 12 subs r0, #1 bge nextbutton$ tst r1, #0b0000000100000000 @@ left subeq px, #1 tst r1, #0b0000001000000000 @@ right addeq px, #1 tst r1, #0b0000100000000000 @@ down addeq py, #1 tst r1, #0b0000010000000000 @@ up subeq py, #1 mov r0, #256 mov r1, #240 mov r2, fbp mov r3, px mov r4, py mov r5, #16 mov r6, #16 ldr r7, =spritesheet bl blit_clip b render$@ ==============================================================================@ Blit a spritesheet var dst, r0 var src, r1 var drofs, r2 var srofs, r3 var rowsiz, r4 var nrows, r5blit: push {r6-r8} add r6, srofs, rowsiz mul r6, nrows add r6, srcouter$: add r7, src, rowsizinner$: ldrb r8, [src] strb r8, [dst] add src, #1 add dst, #1 cmp src, r7 blt inner$ add dst, r2 add src, r3 cmp src, r6 blt outer$ pop {r6-r8} mov pc, lr@ ==============================================================================@ Blitting done with clipping var dw, r0 var dh, r1 var dst, r2 var sx, r3 var sy, r4 var sw, r5 var sh, r6 var src, r7blit_clip: var drofs, r8 var srofs, r9 var rowsiz, r10 var nrows, r11 push {r8-r12} mov drofs, #0 mov srofs, #0 mov rowsiz, sw mov nrows, sh cmp sx, #0 addgt drofs, sx addgt dst, sx sublt src, sx addlt rowsiz, sx add sx, sw subs sx, dw, sx addgt drofs, sx addlt rowsiz, sx cmp sy, #0 mullt r12, sy, sw sublt src, r12 addlt nrows, sy mulgt r12, sy, dw addgt dst, r12 add sy, sh subs sy, dh, sy addlt nrows, sy mov r0, dst mov r1, src mov r2, drofs mov r3, srofs mov r4, rowsiz mov r5, nrows pop {r8-r12} b blit@ ============================================================================== .poolspritesheet: .byte 1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2 .byte 2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1 .byte 1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2 .byte 2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1 .byte 1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2 .byte 2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1 .byte 1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2 .byte 2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1 .byte 1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2 .byte 2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1 .byte 1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2 .byte 2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1 .byte 1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2 .byte 2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1 .byte 1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2 .byte 2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1 .align 12framebufinfo: .int 640 .int 480 .int 256 .int 240 .int 0 .int 8 .int 0 .int 0 .int 0 .int 0OK thats all for now, time to go to bed smile.png Thanks for stopping by!

1
Sign in to follow this  
Followers 0


1 Comment


This brings back fond memories of getting an snes controller to work with zsnes back in the day. Have fun!

0

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now