Advertisement
SMicro

GENERADOR DE CUADRÍCULA

May 11th, 2023 (edited)
1,349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. *-----------------------------------------------------------
  2. * Title      :Generador de Cuadrícula
  3. * Written by :Fulgencio
  4. * Date       :
  5. * Description:
  6. *-----------------------------------------------------------
  7.     ORG    $1000
  8.    
  9. ORIX EQU 50
  10. ORIY EQU 50
  11. SIZE EQU 30
  12. ROWS EQU 5
  13. COLS EQU 5
  14. DRAWLINE EQU 84
  15. DRAWCIRC EQU 88
  16.  
  17.    
  18. START:                 ; first instruction of program
  19.  
  20. * Put program code here
  21.  
  22.     JSR CUADRICULA
  23.     MOVE.W #2,D1
  24.     MOVE.W #3,D2
  25.     JSR CIRCULO
  26.     SIMHALT             ; halt simulator
  27.    
  28.  
  29. CUADRICULA  **************GENERA UNA CUADRÍCULA A PARTIR DE LAS CONSTANTES EQU DEFINIDAS ***************
  30.     MOVEM.L D0-D4,-(A7)
  31.     MOVE.W #ORIX,D1    *Nos ponemos en el origen D1 y D2
  32.     MOVE.W #ORIY,D2
  33. VERTICALES
  34.    
  35.     MOVE.W D1,D3        *El otro extremo de las líneas en D3,D4
  36.     MOVE.W D2,D4
  37.     ADD.W #ROWS*SIZE,D4 *En las líneas verticales solo cambia la coordenada vertical (D4)
  38.     MOVE.L #DRAWLINE,D0
  39.     TRAP #15
  40.    
  41.     ADD.W #SIZE,D1
  42.     CMP.W #ORIX+SIZE*(COLS+1),D1
  43.     BNE VERTICALES
  44.    
  45.     MOVE.W #ORIX,D1     *Nos ponemos en el origen D1 y D2
  46.     MOVE.W #ORIY,D2
  47.    
  48. HORIZONTALES  
  49.  
  50.     MOVE.W D1,D3        *El otro extremo de las líneas en D3,D4
  51.     MOVE.W D2,D4
  52.     ADD.W #COLS*SIZE,D3 *En las líneas horizontales solo cambia la coordenada horizontal (D3)
  53.     MOVE.L #DRAWLINE,D0
  54.     TRAP #15
  55.    
  56.     ADD.W #SIZE,D2
  57.     CMP.W #ORIY+SIZE*(ROWS+1),D2
  58.     BNE HORIZONTALES
  59.    
  60.     MOVEM.L (A7)+,D0-D4
  61.     RTS   *********************************************************************
  62.    
  63. CIRCULO  **************DIBUJA UN CÍRCULO EN COORDENADAS DE CUADRÍCULA FILA = D2, COL= D1 comenzando en 0,0 *********
  64.     MOVEM.L D0-D4,-(A7)
  65.    
  66.     MULU #SIZE,D1    *Escalamos al tamaño de casilla
  67.     MULU #SIZE,D2
  68.     ADD.W #ORIX,D1   *Sumamos el origen
  69.     ADD.W #ORIY,D2
  70.     MOVE.W D1,D3     *Calculamos la otra esquina en D3 y D4 sumando SIZE
  71.     MOVE.W D2,D4
  72.     ADD.L #SIZE,D3
  73.     ADD.L #SIZE,D4
  74.     MOVE.L #DRAWCIRC,D0
  75.     TRAP #15         *Dibujamos el círculo
  76.    
  77.     MOVEM.L (A7)+,D0-D4
  78.     RTS    
  79.  
  80. * Put variables and constants here
  81.  
  82.     END    START        ; last line of source
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement