flat assembler
Message board for the users of flat assembler.

Index > Non-x86 architectures > ARM Development Studio (GBA) + 7 Examples

Author
Thread Post new topic Reply to topic
m3ntal



Joined: 08 Dec 2013
Posts: 296
m3ntal 08 Dec 2013, 14:50
Unofficial ARM GBA Studio.

Includes FASMARM Assembler, Magic-ARM Compiler (Beta), D-ARM7 Disassembler, examples, media/graphics (icons, cursors, images).

All \EXAMPLES\ and \PROJECTS\ will assemble + execute where they are with no setup and they all have access to the same files in \INCLUDE\ and \MEDIA\.

* \BINARY\ - Development programs
* \UTILITY\ - Small utilities, file conversions
* \EXAMPLES\ - 7 examples. Source+.GBA
* \PROJECTS\ - User created projects. 3 templates
* \INCLUDE\ - Magic-Compiler (LANGUAGE.INC) + library files: TEXT.INC, DRAW.INC, FONT.INC, etc
* \MEDIA\ - Multi-media files, graphics+sounds, controls: FONT, ICON, CURSOR, SPRITE, STAGE, etc
* \EMULATOR\ - ARM emulators. To setup, download VBA then copy VISUALBOYADVANCE.EXE (1.88MB) to \EMULATOR\VBA\

Preview:
Code:
;                     _
;  ?__. .__ __ ____ _(_) __?
;  /  |/  / @ `/ $ `/ / __/
; /_/|_/_/\_,_/\_, /_/\__/
;             /___/

;    Magic-ARM Compiler

; erase screen with color/a1...

function clear.screen
 alias vga=a3, w=a2, c=a1
 . vga=VRAM, w=SCREEN.N
 .repeat w
   . (u16) *vga++=c
 .endr
endf

; address &vga[(y*(screen.w*2))+(x*2)]...

function vga.xy
 . a3=SCREEN.PITCH, a4=a2*a3
 . a4=a4+(a1<<1), a2=VRAM, a1=a2+a4
endf

; draw pixel: a1-a3=x/y/c...

function draw.pixel
 alias vga=a1, c=v1
 . c=a3
 vga.xy
 . (u16) *vga=c
endf

; draw horizontal line: a1-a4=x/y/w/c...

function draw.line.h
 alias vga=a1, c=v1, w=v2
 . c=a4, w=a3
 vga.xy
 .repeat w
   . (u16) *vga++=c
 .endr
endf       

; text.n(t) - get text length, # characters

function text.n
 alias t=a1, b=a2, c=v1
 . c=1, b=t
 .while c           ; until 0
   . (u8) c=*t++    ; read c
 .endw
 . t--, t-b         ; return current-start
endf

; text.copy(a, b) - standard copy with 0 after

function text.copy
 alias a=a1, b=a2, c=v1
 . c=1
 .while c
   . (u8) c=*b++    ; read
   . (u8) *a++=c    ; copy
 .endw
 . a--              ; return end
endf

; text.attach(a, b) - attach b to a

function text.attach
 alias a=a1,\
  b=a2, p=v1
 . p=b
 text.end
 . b=p
 text.copy
endf

; text.attach.c(t, c) - attach c to t

function text.attach.c
 alias t=a1, c=v2
 . c=a2
 text.end
 . (u8) *t++=c, (u8) *t=0
endf

; text.find(t, c) - search for character.
; return address or 0

function text.find
 alias t=a1,\
  c=v1, key=a2
 .forever           ; loop
   . (u8) c=*t      ; read c
   .if c=0          ; end?
     return 0       ; not found
   .end
   .if c=key        ; found?
     return t       ; t=address
   .end
   . t++            ; next
 .endfv
endf

; text.compare(a, b) - lexical comparison.
; return <0>

function text.compare
 alias a=a1, b=a2,\
  c=v1, d=v2
  . c=1, d=c
 .while c=d         ; while equal
   . (u8) c=*a++
   . (u8) d=*b++
   . c|d            ; and both nonzero
   .breakz          ; break if either=0
 .endw
 . a=c-d            ; return *a-*b
endf

; text.upper(t) - convert to uppercase

function text.upper
 alias t=a1, c=v1
 .forever
   . (u8) c=*t      ; get c
   .if c=0          ; end?
     return t
   .end
   .if c>=97        ; lowercase?
     .if c<=122
       . c-32
       . (u8) *t=c  ; copy c
     .end
   .end
   . t++            ; next c
 .endfv
endf

; convert unsigned 32BIT integer to text

 .while n           ; until 0
   . y=n            ; dividend
   . x=1999999Ah    ; ((2^32)/10)+1
   . n=n-(n>>>30)   ; n=n-(n>>>30)
   umull c, n, n, x ; divide: n*reciprocal
   . x=n<<1         ; multiply by 10
   . x=x+(x<<2)
   . x=y-x          ; remainder
   . c=x+30h        ; c=(n%10)+'0'
   . (u8) *t++=c    ; *t++=c
 .endw

; convert 32BIT binary number to text

 .while n            ; *t++=(n&1)+'0'
   . x=n&1, x+30h
   . (u8) *t++=x
   . n>>>1           ; n/2
 .endw
 . (u8) *t=0, a1=s

; convert bgr15 to rgb15

function convert.bgr15.rgb24
 alias r=a1, g=a2, b=a3, c=a4
 . c=a1, r=c&11111b, r<<3
 . g=c>>5, g&11111b, g<<3
 . b=c>>10, b&11111b, b<<3
 . c=r<<16, r=c|(g<<8), r|b
endf   

; return r/g/b in a1-a3 from bgr15

function get.rgb15
 alias r=a1, g=a2, b=a3, c=a4
 . c=a1, r=c&11111b, g=c>>5, g&11111b
 . b=c>>10, b&11111b
endf

; draw solid rectangle: a1-v1=x/y/w/h/c...

function draw.box
 alias vga=a1, c=v1,\
  sw=v2, w=v3, h=v4,\
  pitch=a2, wb=a3
 . w=a3, sw=w, h=a4    ; save w/h
 vga.xy
 . pitch=SCREEN.PITCH  ; screen+row
 . wb=w<<1             ; w in bytes
 .repeat h             ; h # times
   . w=sw              ; reset saved
   .repeat w           ; w # times
     . (u16) *vga++=c  ; copy color
   .endr
   . vga+pitch, vga-wb ; advance
 .endr
endf

; draw 15/16BPP bitmap. a1-a4=x/y/w/h.
; v1=pixels...   

 . pitch=SCREEN.PITCH   ; screen+image
 . iwb=w<<1             ; w in bytes
 vga.xy                 ; &vga(x,y)
 .repeat h              ; h # times
   . w=sw               ; get saved w
   .repeat w            ; w # times
     . (u16) \
      *vga++=*image++   ; copy pixel
   .endr
   . vga+pitch, vga-iwb ; advance
 .endr   

; draw 15/16BPP bitmap with transparency
; by upper left pixel color (0x0).
; a1-a4=x/y/w/h. v1=pixels...  

 . pitch=SCREEN.PITCH   ; screen+image
 . iwb=w<<1             ; w in bytes
 . (u16) key=*image     ; transparent color
 vga.xy                 ; &vga(x,y)
 .repeat h              ; h # times
   . w=sw
   .repeat w            ; w # times
     . (u16) c=*image++
     .if c<>key         ; opaque?
       . (u16) *vga++=c ; copy pixel
     .else
       . vga+2          ; next
     .end
   .endr
   . vga+pitch, vga-iwb ; advance
 .endr

; draw 15/16BPP scanline. a1-a3/v1=x/y/w/pixels...

function draw.scanline
 alias vga=a1,\        ; aliases
  p=v1, w=v2
 . w=a3, p=v1          ; save w/p
 vga.xy                ; &vga(x,y)
 .repeat w             ; w # times
   . (u16) *vga++=*p++ ; copy pixel
 .endr
endf

; draw bitmap text (FONT.INC)...

function draw.text
 alias t=v1,\             ; aliases
  x=v2, y=v3,\
  c=v5, fw=v6, ix=v7
 . t=a1, x=a2, y=a3       ; save these
 . ix=x
 . fw=FW                  ; font w
 . (u8) c=*t
 .while c                 ; while nonzero
   . (u8) c=*t++          ; get next c
   .if c=0Dh              ; return?
     . t++                ; skip 0Ah after
     . x=ix, x-fw, y+FH   ; reset x/y
   .end
   draw.c c, x, y         ; draw character
   . x+fw                 ; x+font.w
 .endw
endf    

(Keywords for search engines: programming ARM ASM assembler assembly tutorials how to learn introduction beginner manual bare metal GBA gameboy advance SP raspberry pi instruction reference encodings list decode register memory ip sp lr pc load relative mov ldr adr immediate constant address branch pipeline THUMB 1 2 FPA VFP SIMD NEON bios interrupt coprocessor emulator disassembler simulator)


Description: Sketch for FASM IDE in 240x160 BGR15. See APPLICATION in \EXAMPLES\ and \INCLUDE\. Easy conversion to ARM embedded systems. VBA settings: Options>Video>X3. Filter>HQ2X
Filesize: 110.67 KB
Viewed: 25488 Time(s)

gba1.jpg


Description: ARM GBA Studio
Download
Filename: arm_gba_studio.zip
Filesize: 542.58 KB
Downloaded: 1338 Time(s)

Post 08 Dec 2013, 14:50
View user's profile Send private message Reply with quote
m3ntal



Joined: 08 Dec 2013
Posts: 296
m3ntal 08 Dec 2013, 14:52
Screenshots:


Description: Magic-Compiler Syntaxes
Filesize: 210.18 KB
Viewed: 25487 Time(s)

magic_c.jpg


Description:
Filesize: 86.17 KB
Viewed: 25486 Time(s)

gba3.jpg


Description:
Filesize: 104.98 KB
Viewed: 25486 Time(s)

gba2.jpg


Post 08 Dec 2013, 14:52
View user's profile Send private message Reply with quote
nop



Joined: 01 Sep 2008
Posts: 165
Location: right here left there
nop 09 Dec 2013, 08:22
welcome back uart777 Wink great work Cool
Post 09 Dec 2013, 08:22
View user's profile Send private message Reply with quote
ctl3d32



Joined: 30 Dec 2009
Posts: 206
Location: Brazil
ctl3d32 09 Dec 2013, 11:16
hauahuhuha
Post 09 Dec 2013, 11:16
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 09 Dec 2013, 11:34
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 19:08; edited 1 time in total
Post 09 Dec 2013, 11:34
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20416
Location: In your JS exploiting you and your system
revolution 09 Dec 2013, 13:02
HaHaAnonymous wrote:
How do you know it is uart777?

It can be a fake or something. All possibilities must be considered. Razz
Well I guess it could be a very unlikely coincidence. But one way to confirm is to check the server logs. I won't say either way since it is more fun to watch you all keep guessing Twisted Evil
Post 09 Dec 2013, 13:02
View user's profile Send private message Visit poster's website Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 09 Dec 2013, 17:58
Its got to be him, there can not be two people putting out s**t like that.

Anyway i thought you was working on a usb stack for the RPI, was it too hard for you ?, i thought so.
Mines almost finished.
Post 09 Dec 2013, 17:58
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 09 Dec 2013, 20:02
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 19:06; edited 1 time in total
Post 09 Dec 2013, 20:02
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 13 Dec 2013, 07:51
HaHaAnonymous wrote:
Quote:

I won't say either way since it is more fun to watch you all keep guessing

Haha, you like these types of games. Like not telling if you are male or female...


Hahahahahaha. I thought we solved this mystery already. We came to a conclusion that revolution is woman...or not.
Post 13 Dec 2013, 07:51
View user's profile Send private message Reply with quote
m3ntal



Joined: 08 Dec 2013
Posts: 296
m3ntal 13 Dec 2013, 16:59
What are you guys talking about? This post is supposed to be about ARM programming. Why do you get personal and change the subject?

I'm requesting that all replies to this be deleted or moved.
Post 13 Dec 2013, 16:59
View user's profile Send private message Reply with quote
sid123



Joined: 30 Jul 2013
Posts: 339
Location: Asia, Singapore
sid123 23 Dec 2013, 06:33
Nice examples, would consider it when I am over with x86 assembly,
(can't concentrate on two things, ARM and x86 Razz)
So it's something like Visual Studio? Like some sort of IDE,
Also, where did you get those cool windows, Z-Console? Is that your OS?
All those nice graphics look cool.
Any website or something?
Post 23 Dec 2013, 06:33
View user's profile Send private message Reply with quote
m3ntal



Joined: 08 Dec 2013
Posts: 296
m3ntal 25 Dec 2013, 19:37
Quote:
So it's something like Visual Studio?
A development package or the beginning of one. My dream is to create a replacement for Visual Studio that has true portability: X86, ARM, WinX, Linux, Android. The IDE is a sketch (see EXAMPLES\APPLICATION.GBA) for FASM on ARM and my own assemblers and compilers.
Quote:
Also, where did you get those cool windows, Z-Console?
I create them by myself. Drawing Windows is easy, they're just rectangles with outlines and shading. See: INCLUDE/DRAW.INC. Same algorithms apply to any CPU/OS.[quote

MAGIC-ARM FUNCTIONS

First Real ARM Macro Language + Library. Pure LL register usage. Highly Portable Text + Graphics. Preview:
Code:
; memory.set p, v, n
; memory.copy a, b, n
; memory.zero p, n

; text.n t          ; get # characters (size-1)
; text.copy a, b    ; standard copy with 0 after
; text.copy.n ...   ; copy with maximum size
; text.attach a, b  ; attach b to a; "concencate"
; text.attach.c...  ; attach character
; text.compare a, b ; compare. return <0>
; text.find t, c    ; search for c. return &/0
; text.find.last... ; search for c reverse
; text.begins a, b  ; begins with b?
; text.ends a, b    ; ends with b?
; text.upper t      ; convert to uppercase
; text.lower t      ; convert to lowercase
; text.reverse t    ; reverse

; i2t n, t          ; number/text conversions
; u2t n, t
; h2t n, t
; b2t n, t

; vga.xy x, y ; &vga[xy(x,y)]
; color.at    ; vga[xy(x,y)]

; clear.screen

; locate x, y, w, h
; draw.pixel x, y, c
; draw.line.h x, y, w, c
; draw.line.v x, y, h, c
; draw.scanline x, y, w, p
; draw.scanline.t x, y, w, p
; draw.scanline.v x, y, w, p, c
; draw.box x, y, w, h, c
; draw.box.a x, y, w, h, c, a
; draw.outline x, y, w, h, c
; draw.box.o x, y, w, h, c, c2
; draw.bitmap x, y, w, h, p
; draw.bitmap.t x, y, w, h, p
; draw.bitmap.a x, y, w, h, p, a
; draw.fade x, y, w, h, c, c2
; draw.shade x, y, w, h, c, c2

; create.console
; draw.console
; putx x, s
; putc x
; putt x
; puts x
; putn n, name
; puti n
; putu n
; puth n
; putb n    
Post 25 Dec 2013, 19:37
View user's profile Send private message Reply with quote
dstyl



Joined: 23 Jul 2015
Posts: 67
dstyl 08 Aug 2015, 02:50
Serious hot stuff, already took out my flash card thumbs up man !
Post 08 Aug 2015, 02:50
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.