Author Topic: BBify: syntax-color your Z80, TI-BASIC, Axe, and Lua  (Read 38876 times)

0 Members and 1 Guest are viewing this topic.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
BBify: syntax-color your Z80, TI-BASIC, Axe, and Lua
« on: June 24, 2011, 06:35:20 pm »
BBify

A little web project I've been working on.

I know it looks horrible, but I'll prettify it up soon. At least it's functional: paste in some Z80 code and click Submit, and it'll wrap stuff in BBCode so you can copy-paste the result straight into a forum. Or HTML, so you can paste it into a webpage, or plain old colored code, so you can paste it into an email!

Right now it can only handle strings, numbers, comments, and directives, but the way I've set it up all I have to do is add a regex array element for any replacements I want to do and it'll put that on the queue.

Better yet, I'm planning to add customized colors. Right now I'm taking colors off the Tango scheme, but the way I have it set up I can just add some form elements and you'll be able to change the colors to whatever you want :D

Latest update: http://ourl.ca/9167/289088/
« Last Edit: May 12, 2013, 03:09:20 pm by Deep Thought »




Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #1 on: June 24, 2011, 06:36:35 pm »
This is nice O.O. I wonder if eventually it could be integrated in the forum or something? I think there's a SMF hack ephans/Scout posted that does that with PHP/C++, but someone could modify it to do it with Z80 instead.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #2 on: June 24, 2011, 06:37:47 pm »
Yeah, I wasn't aware of that one when I started making this :-\




Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #3 on: June 24, 2011, 06:38:22 pm »
Deep Thought, very nice :D I'd like this on the forums like DJ :)

Test:
; Program Name: Memory Checker
; Author: David Gomes
; Version: <<1>>.<1>
; Written for Doors CS <<1>>.<1> and higher
.nolist
#include "ti83plus.inc"
#include "dcs7.inc"
.list
   .org progstart
   .db $BB,$6D
Init:
  B_CALL (_ClrLCDFull)
 
  set textWrite,(IY + sGrFlags)
  set fracDrawLFont,(IY + fontFlags)
 
  ld a,1
  ld (penCol), a
  ld (penRow), a
  ld hl,Title
  B_CALL (_VPutS)
 
  ld a,17
  ld (penRow),a
  ld a,1
  ld (penCol),a
  ld hl,RAMText
  B_CALL (_VPutS)
 
  ld a,41
  ld (penRow),a
  ld a,1
  ld (penCol),a
  ld hl,ARCText
  B_CALL (_VPutS)
 
  ld h,0
  ld l,9
  ld d,95
  ld e,9
  ld a,1
  call fastline
 
  res fracDrawLFont,(IY + fontFlags)
 
  ld a,10
  ld (penRow),a
  ld a,20
  ld (penCol),a
  B_CALL (_memchk)
  call VDispHL
 
  ld a,17
  ld (penRow),a
  ld a,20
  ld (penCol),a
  ld hl,OutOf
  B_CALL (_VPutS)
 
  ld a,24
  ld (penRow),a
  ld a,20
  ld (penCol),a
  ld hl,24756
  call VDispHL
 
  call GetFreeArc
  ld a,35
  ld (penRow),a
  ld a,20
  ld (penCol),a
  B_CALL (_VPutS)
 
  ld a,41
  ld (penRow),a
  ld a,20
  ld (penCol),a
  ld hl,OutOf
  B_CALL (_VPutS)
 
  call GetTotalArc
  ld a,47
  ld (penRow),a
  ld a,20
  ld (penCol),a
  B_CALL (_VPutS)
 
  call iFastCopy
  B_CALL (_GetKey)
 
  res textWrite,(IY + sGrFlags)
 
  ret

RAMText:
  .db <0>,0

ARCText:
  .db <0>,0

Title:
  .db <0>,0

OutOf:
  .db <0>,0

;The following code was made by Runer112
GetTotalArc:
;——————————————————————————————————————————————;
;—> Returns the total amount of user archive as a <0>-character decimal string
;INPUTS:    none
;OUTPUTS:   hl=pointer to string (OP3)
;DESTROYS:  af  bc  de  ix
;——————————————————————————————————————————————;
  B_CALL($80BA)
  add   a,a
  add   a,a
  ld   d,0
  ld   e,a
  ld   hl,GetTotalArc_HWValues
  add   hl,de
  jr   ConvArc
GetTotalArc_HWValues:
  .db   (10*$4000)>;><3>&<4>,(<0><1><2>)>><<13>>&<4>,(<0><1><2>)>><13>&<4>,(<0><1><2>)&<4>
  .db   (94*$4000)>;><3>&<4>,(<0><1><2>)>><<13>>&<4>,(<0><1><2>)>><13>&<4>,(<0><1><2>)&<4>
  .db   (30*$4000)>;><3>&<4>,(<0><1><2>)>><<13>>&<4>,(<0><1><2>)>><13>&<4>,(<0><1><2>)&<4>
  .db   (94*$4000)>;><3>&<4>,(<0><1><2>)>><<13>>&<4>,(<0><1><2>)>><13>&<4>,(<0><1><2>)&<4>

GetFreeArc:
;——————————————————————————————————————————————;
;—> Returns the amount of free archive as a <0>-character decimal string
;INPUTS:    none
;OUTPUTS:   hl=pointer to string (OP3)
;DESTROYS:  af  bc  de  ix
;——————————————————————————————————————————————;
  B_CALL($5014)      ;ArcChk
  ex   de,hl
  inc   hl


ConvArc:
;——————————————————————————————————————————————;
;—> Converts a <0>-bit integer into a <1>-character decimal string
;INPUTS:    hl=pointer to <0>-bit integer (big-endian)
;OUTPUTS:   hl=pointer to string (OP3)
;DESTROYS:  af  bc  de  ix
;——————————————————————————————————————————————;
  rst   20h
  ld   hl,OP3+7
  ld   de,10
  ld   (hl),d
  ld   b,7
ConvArc_Loop1:
  push   bc
  push   hl
  B_CALL($80B1)      ;Div32By16
  pop   hl
  pop   bc
  ld   a,(OP2+3)
  add   a,'0'
  dec   hl
  ld   (hl),a
  djnz   ConvArc_Loop1
  ld   d,h
  ld   e,l
  ld   bc,6<;<<1>+<2>
ConvArc_Loop2:
  ld   a,(de)
  cp   c
  ret   nz
  ld   a,' '
  ld   (de),a
  inc   de
  djnz   ConvArc_Loop2
  ret

« Last Edit: June 24, 2011, 06:40:33 pm by ephan »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #4 on: June 24, 2011, 06:39:22 pm »
Yeah, I wasn't aware of that one when I started making this :-\
Nah it's fine. Plus yours is independent from forums, so your tool can still be used on forums that lacks this.

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #5 on: June 24, 2011, 06:39:56 pm »
Nice :)

Could be nice if it gets integrated in the forum indeed.

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #6 on: June 24, 2011, 06:43:47 pm »
GetTotalArc_HWValues:
  .db   (10*$4000)>;><3>&<4>,(<0><1><2>)>><<13>>&<4>,(<0><1><2>)>><13>&<4>,(<0><1><2>)&<4>
  .db   (94*$4000)>;><3>&<4>,(<0><1><2>)>><<13>>&<4>,(<0><1><2>)>><13>&<4>,(<0><1><2>)&<4>
  .db   (30*$4000)>;><3>&<4>,(<0><1><2>)>><<13>>&<4>,(<0><1><2>)>><13>&<4>,(<0><1><2>)&<4>
  .db   (94*$4000)>;><3>&<4>,(<0><1><2>)>><<13>>&<4>,(<0><1><2>)>><13>&<4>,(<0><1><2>)&<4>


Eek, bugs! Mind posting your original code for me?




Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #8 on: June 24, 2011, 06:45:09 pm »
Thanks, I'll work on fixing it soon :)




Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #9 on: June 24, 2011, 07:52:07 pm »
BootExe:
; File Header
   dw BootExeEnd-BootExe   ; Size of File
; Executable Header
   db 0         ; Size of Stack needed
BootExeStart:
; End Headers Start Data
   ldrDE(_-BootExeStart)
   call LoadFileToRAM
   if(SUCCESS)
      jp nz, KernelPanic
   ex de,hl
   rDrawWrappedString
   rFastCopy
   call FlushKeys
   call WaitKey
   rEndThread
_   db <0>,0
BootExeEnd:

Hrm, it seems to not parse db "string",0 statements correctly
everything else is great though, maybe add in some highlighting for commands too?
/e

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #10 on: June 24, 2011, 08:04:34 pm »
Hrm, it seems to not parse db "string",0 statements correctly

Yeah, there are a few issues with numbers.

everything else is great though, maybe add in some highlighting for commands too?

Definitely, and also registers, bcalls, and everything else I highlight in my gedit scheme file.




Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #11 on: June 24, 2011, 08:12:56 pm »
Hrm, it seems to not parse db "string",0 statements correctly

Yeah, there are a few issues with numbers.

everything else is great though, maybe add in some highlighting for commands too?

Definitely, and also registers, bcalls, and everything else I highlight in my gedit scheme file.
Maybe add in support for KOS and RogueOS calls too? ( when they are finalized of course )
/e

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #12 on: June 24, 2011, 08:33:13 pm »
Hrm, it seems to not parse db "string",0 statements correctly

Yeah, there are a few issues with numbers.

everything else is great though, maybe add in some highlighting for commands too?

Definitely, and also registers, bcalls, and everything else I highlight in my gedit scheme file.
Maybe add in support for KOS and RogueOS calls too? ( when they are finalized of course )

Sure. No need to give me the actual call lists because it's all just regex -- it highlights the instruction bcall/kcall/rcall one way, then assumes whatever's in the parentheses following or the next word is the routine.




Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #13 on: July 03, 2011, 08:56:39 pm »
Update-bump: instructions, registers, operators, all that fun stuff. I also fixed those annoying bugs.

Spoiler For ephan's code posted earlier:
; Program Name: Memory Checker
; Author: David Gomes
; Version: 1.0
; Written for Doors CS 7.0 and higher
.nolist
#include "ti83plus.inc"
#include "dcs7.inc"
.list
        .org progstart
        .db $BB,$6D
Init:
  B_CALL (_ClrLCDFull)
 
  set textWrite,(IY + sGrFlags)
  set fracDrawLFont,(IY + fontFlags)
 
  ld a,1
  ld (penCol), a
  ld (penRow), a
  ld hl,Title
  B_CALL (_VPutS)
 
  ld a,17
  ld (penRow),a
  ld a,1
  ld (penCol),a
  ld hl,RAMText
  B_CALL (_VPutS)
 
  ld a,41
  ld (penRow),a
  ld a,1
  ld (penCol),a
  ld hl,ARCText
  B_CALL (_VPutS)
 
  ld h,0
  ld l,9
  ld d,95
  ld e,9
  ld a,1
  call fastline
 
  res fracDrawLFont,(IY + fontFlags)
 
  ld a,10
  ld (penRow),a
  ld a,20
  ld (penCol),a
  B_CALL (_memchk)
  call VDispHL
 
  ld a,17
  ld (penRow),a
  ld a,20
  ld (penCol),a
  ld hl,OutOf
  B_CALL (_VPutS)
 
  ld a,24
  ld (penRow),a
  ld a,20
  ld (penCol),a
  ld hl,24756
  call VDispHL
 
  call GetFreeArc
  ld a,35
  ld (penRow),a
  ld a,20
  ld (penCol),a
  B_CALL (_VPutS)
 
  ld a,41
  ld (penRow),a
  ld a,20
  ld (penCol),a
  ld hl,OutOf
  B_CALL (_VPutS)
 
  call GetTotalArc
  ld a,47
  ld (penRow),a
  ld a,20
  ld (penCol),a
  B_CALL (_VPutS)
 
  call iFastCopy
  B_CALL (_GetKey)
 
  res textWrite,(IY + sGrFlags)
 
  ret
 
RAMText:
  .db "RAM",0
 
ARCText:
  .db "ARC",0
 
Title:
  .db "Memory Checker",0
 
OutOf:
  .db "out of",0
 
;The following code was made by Runer112
GetTotalArc:
;——————————————————————————————————————————————;
;—> Returns the total amount of user archive as a 7-character decimal string
;INPUTS:    none
;OUTPUTS:   hl=pointer to string (OP3)
;DESTROYS:  af  bc  de  ix
;——————————————————————————————————————————————;
  B_CALL($80BA)
  add   a,a
  add   a,a
  ld    d,0
  ld    e,a
  ld    hl,GetTotalArc_HWValues
  add   hl,de
  jr    ConvArc
GetTotalArc_HWValues:
  .db   (10*$4000)>>24&$FF,(10*$4000)>>16&$FF,(10*$4000)>>8&$FF,(10*$4000)&$FF
  .db   (94*$4000)>>24&$FF,(94*$4000)>>16&$FF,(94*$4000)>>8&$FF,(94*$4000)&$FF
  .db   (30*$4000)>>24&$FF,(30*$4000)>>16&$FF,(30*$4000)>>8&$FF,(30*$4000)&$FF
  .db   (94*$4000)>>24&$FF,(94*$4000)>>16&$FF,(94*$4000)>>8&$FF,(94*$4000)&$FF
 
GetFreeArc:
;——————————————————————————————————————————————;
;—> Returns the amount of free archive as a 7-character decimal string
;INPUTS:    none
;OUTPUTS:   hl=pointer to string (OP3)
;DESTROYS:  af  bc  de  ix
;——————————————————————————————————————————————;
  B_CALL($5014)         ;ArcChk
  ex    de,hl
  inc   hl
 
 
ConvArc:
;——————————————————————————————————————————————;
;—> Converts a 32-bit integer into a 7-character decimal string
;INPUTS:    hl=pointer to 32-bit integer (big-endian)
;OUTPUTS:   hl=pointer to string (OP3)
;DESTROYS:  af  bc  de  ix
;——————————————————————————————————————————————;
  rst   20h
  ld    hl,OP3+7
  ld    de,10
  ld    (hl),d
  ld    b,7
ConvArc_Loop1:
  push  bc
  push  hl
  B_CALL($80B1)         ;Div32By16
  pop   hl
  pop   bc
  ld    a,(OP2+3)
  add   a,'0'
  dec   hl
  ld    (hl),a
  djnz  ConvArc_Loop1
  ld    d,h
  ld    e,l
  ld    bc,6<<8+'0'
ConvArc_Loop2:
  ld    a,(de)
  cp    c
  ret   nz
  ld    a,' '
  ld    (de),a
  inc   de
  djnz  ConvArc_Loop2
  ret
« Last Edit: July 03, 2011, 09:17:19 pm by Deep Thought »




Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #14 on: July 04, 2011, 01:26:30 pm »
Another (huge) update-bump:
  • Finally, a real UI. It's no longer two text boxes and a ginormous button.
  • Custom colors! Dynamic preview too for the heck of it.
  • AJAX updating instead of the form (if you have Javascript enabled), making each submission much, much faster. Still works without JS (for once).
  • Upload a file! It even echoes anything inside back into the text box so you can keep tweaking it without leaving the page.
EDIT: And now I got banned from my own website x.x
« Last Edit: July 04, 2011, 06:01:46 pm by Deep Thought »