?login_element?

Subversion Repositories NedoOS

Rev

Rev 126 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ; this is example of "for ... next" like logic recreated by current sjasmplus syntax
  2.  
  3. ; The original example source (coming from one "can I do something like..." discussion):
  4. ;
  5. ;     for half=$0000 to $0800 step $0800       ; This is calculated so it works for any buffer address.
  6. ;         for y=$0000 to $00E0 step $0020        ; (in theory)
  7. ;             for x=$0000 to $0700 step $0100
  8. ;                 dw ScreenBufferCWGI+x+y+half
  9. ;             next
  10. ;         next
  11. ;     next
  12.  
  13. ;; first version - does work as intended, exploits DUP directive, looks ugly
  14.  
  15.     MACRO instanceExample half.from?, half.to?, half.step?
  16. .HALF=half.from?
  17.         DUP 1+(half.to? - half.from? + half.step? - 1) / half.step?
  18. .Y=0
  19.             DUP 1+($E0 / $20)
  20. .X=0
  21.                 DUP 1+($700/$100)
  22.                     ;DISPLAY "Doing DW with [half: ", .HALF, " y: ", .Y, " x: ", .X, "]"
  23.                     dw ScreenBufferCWGI + .X + .Y + .HALF
  24. .X=.X+$100
  25.                 EDUP
  26. .Y=.Y+$20
  27.             EDUP
  28. .HALF=.HALF + half.step?
  29.         EDUP
  30.     ENDM
  31.  
  32.     OUTPUT "fake_for1.bin"
  33. ScreenBufferCWGI=$4000
  34.     instanceExample $0, $800, $800
  35.