易码技术论坛

 找回密码
 加入易码
搜索
查看: 194342|回复: 3

原创:矩形贴图函数

[复制链接]
发表于 2007-1-29 11:50:36 | 显示全部楼层
貌似代码的第18($12)行应该是:  inc $83吧!
 楼主| 发表于 2007-1-29 13:53:12 | 显示全部楼层
对的,是我粗心打错了哈!!
 楼主| 发表于 2007-3-3 17:54:35 | 显示全部楼层
又新写了两个函数,主要功能是将图片90度旋转.
今天战斗力高涨!哈哈写了两个函数!难度不大,关键是思路满好的!
;图象90度旋转函数
lda #$68
sta $82
lda #$10
sta $83
lda #lly+1
sta $84
loop4:lda #py
sta $03c8
lda #lb+1
sta $87
lda #mx
sta $86
ldy #$00
loop3:lda ($82),y
sta $17ad
ldx #$08
loop2:dec $86
beq loop1
asl $17ad
bcc tt
txa
pha
tya
pha
jsr draw
pla
tay
pla
tax
tt:inc $03c8
dex
bne loop2
iny
clc
bcc loop3
loop1:inc $82
bne mm
inc $83
mm:dec $87
bne loop1
inc $03c7
dec $84
bne loop4
rts

;画点函数($03c5=1是判断该点状况,=0是画点。$03c6存放点的状况)
draw:
ldx $03c8
ldy $03c7
txa
asl
tax
lda $170d,x
sta $80
lda $170e,x
sta $81
tya
and #$07
sta $85
tya
lsr
lsr
lsr
tay
lda #$80
ldx #$00
next:cpx $85
beq jp
inx
jsr
clc
bcc next
jp: ldx $03c5
bne read
ora($80),y
sta ($80),y
rts
read:and ($80),y
sta $03c6
rts
 楼主| 发表于 2007-1-29 02:00:55 | 显示全部楼层 |阅读模式
_GRAPH DW $19c0
;_GraphArea DW $1068
; x1,y1,x2,y2,t,m四个坐标点和两个偏移数值
;GraphAddress首地址为170d
GraphAddress:
  .DW _GRAPH+$0000,_GRAPH+$0014,_GRAPH+$0028,_GRAPH+$003C,_GRAPH+$0050,_GRAPH+$0064,_GRAPH+$0078,_GRAPH+$008C
  .DW _GRAPH+$00A0,_GRAPH+$00B4,_GRAPH+$00C8,_GRAPH+$00DC,_GRAPH+$00F0,_GRAPH+$0104,_GRAPH+$0118,_GRAPH+$012C
  .DW _GRAPH+$0140,_GRAPH+$0154,_GRAPH+$0168,_GRAPH+$017C,_GRAPH+$0190,_GRAPH+$01A4,_GRAPH+$01B8,_GRAPH+$01CC
  .DW _GRAPH+$01E0,_GRAPH+$01F4,_GRAPH+$0208,_GRAPH+$021C,_GRAPH+$0230,_GRAPH+$0244,_GRAPH+$0258,_GRAPH+$026C
  .DW _GRAPH+$0280,_GRAPH+$0294,_GRAPH+$02A8,_GRAPH+$02BC,_GRAPH+$02D0,_GRAPH+$02E4,_GRAPH+$02F8,_GRAPH+$030C
  .DW _GRAPH+$0320,_GRAPH+$0334,_GRAPH+$0348,_GRAPH+$035C,_GRAPH+$0370,_GRAPH+$0384,_GRAPH+$0398,_GRAPH+$03AC
  .DW _GRAPH+$03C0,_GRAPH+$03D4,_GRAPH+$03E8,_GRAPH+$03FC,_GRAPH+$0410,_GRAPH+$0424,_GRAPH+$0438,_GRAPH+$044C
  .DW _GRAPH+$0460,_GRAPH+$0474,_GRAPH+$0488,_GRAPH+$049C,_GRAPH+$04B0,_GRAPH+$04C4,_GRAPH+$04D8,_GRAPH+$04EC
  .DW _GRAPH+$0500,_GRAPH+$0514,_GRAPH+$0528,_GRAPH+$053C,_GRAPH+$0550,_GRAPH+$0564,_GRAPH+$0578,_GRAPH+$058C
  .DW _GRAPH+$05A0,_GRAPH+$05B4,_GRAPH+$05C8,_GRAPH+$05DC,_GRAPH+$05F0,_GRAPH+$0604,_GRAPH+$0618,_GRAPH+$062C
lda #$68
sta $82
lda #$10
sta $83
lda y1
asl
tax
loop2:pha
ldy x1
lda $170d,x
sta $80
lda $170e,x
sta $81
loop1: ldx #00
lda ($82,x)
inc $82
bne cc
inc $83
cc: sta $17ad,y
iny
cpy x2+1
bne loop1
lda #$00
sta $17ad,y
lda t
sta $84
beq mm
next : clc
php
ldx x1
loop3: plp
ror $17ad,x
php
inx
cpx x2+2
bne loop3
plp
dec $84
bne next
mm:ldy x1
lda $17ad,y
ora ($80),y
sta ($80),y
iny
cpy x2+2
bne loop4
pla
tax
inx
inx
txa
cpx (y2+1)*2
bne loop2
rts

新写的截图函数(其实是贴图的逆写法):
lda #$68
sta $82
lda #$10
sta $83
lda #y1
asl
tax
loop2:pha
ldy#$x1
lda $170d,x
sta $80
lda $170e,x
sta $81
loop1: lda($80),y
sta $17ad,y
iny
cpy #x2+1
bne loop1
lda #t
sta $84
beq pp
next:clc
php
ldx #x2
loop3:plp
rol $17ad,x
php
dex
cpx #x1-1
bne loop3
plp
dec $84
bne next
pp:ldy #x1
ldx #$00
loop4:lda $17ad,y
sta ($82,x)
inc $82
bne cc
inc $83
cc:iny
cpy #x2+1
bne loop4
pla
tax
inx
inx
txa
cpx #(y2+1)*2
bne loop2
rts


;lzjseed作品
您需要登录后才可以回帖 登录 | 加入易码

本版积分规则

Archiver|手机版|小黑屋|EMAX Studio

GMT+8, 2024-11-1 07:42 , Processed in 0.010867 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表