;Copyright (C) 2008 Pierre Baudemont ; ; This file is part of bf. ; ; bf is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; ; bf is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with bf; if not, write to the Free Software ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ;--screen backup-- ; PARAM: none ; OUTPT: a0 ; ; The allocated memory used to save the screen content is pointed by a0 ; If memory could not be allocated, a0 is null ; => TEST a0 after calling save_scr ; Used ROM CALLs : ;HeapAllocPtr equ $A2 ;memcpy equ $26A section ".data" include "OS.h" xdef save_scr save_scr: ; save of the used registries movem.l d3/a5,-(a7) ; to use the ROM CALLs move.l $c8,a5 ; allocation sur le tas pour sauvegarder l'écran move.l #3840,-(a7) ;screen: 240x128(=3840o),HeapAllocPtr 1st param move.l HeapAllocPtr*4(a5),a0 jsr (a0) addq.l #4,a7 ;clean the stack move.l a0,d3 ;result of HeapAllocPtr in a0 tst.l d3 ;has to be tested (if null => error) beq nomem ; copy the screen content in the allocated memory move.l #3840,-(a7) ;size (1st param) pea.l $4c00 ;2nd param : @source (LCD mem) move.l d3,-(a7) ;3rd param : @dest move.l memcpy*4(a5),a0 jsr (a0) lea 12(a7),a7 ;clean the stack move.l d3,a0 ;output in a0 nomem: movem.l (a7)+,d3/a5 ;saved registries restoration rts